How using «git archive» in CICD gitlab-pages?

Hello,
I am setting up a blog with gitlab-pages using Pelican. At first I managed to deploy and access a first version that used a theme hosted on github.
But now I would like to use a custom theme hosted on Gitlab repository.

I used the same method of github recommended in the gitlab.ci

  - svn export https://github.com/getpelican/pelican-themes/trunk/<theme-name> /tmp/<theme-name>
  - pelican-themes --install /tmp/the_theme

But gitlab does not support the “svn export” command. The similar command with git is “git archive” which is supported by gitlab but only in SSH version (not HTTPS).
So I try to do

  - mkdir /tmp/<theme-name>
  - ssh -o StrictHostKeyChecking=no git@gitlab.com uptime
  - git archive --prefix=/tmp/<theme-name>/ --remote=git@gitlab.com:<user-name>/<theme-name>.git HEAD

But here I have the error message “Permission denied (publickey)”. Normal since I didn’t put a keys of a gitlab account in parameter.

So I have to use “git clone”.

  - git clone https://gitlab.com/<user-name>/<theme-name>.git /tmp/<theme-name>
  - rm -rf /tmp/<theme-name>/.git

What bothers me is to download and delete the “.git” directory which is useless in my case. The command “git archive” avoids this but I don’t know how to do it without SSH keys from a gitlab account.

Do you have an idea? Is there a cleaner solution?
Thanks in advance

Hi @Mimoza

I haven’t tried this myself, but often you can use the CI_JOB_TOKEN variable in place of user credentials, in the pipeline.

Indeed it seems an interesting way.
Unfortunately I did not find the right formula to use it in the connection chain
If someone have an idea or exemple how to use it, it will be very useful.