2

I keep my development on a personal GitLab server. In my CI/CD script, I want to push the repository to a public GitHub repo when a new tag is created.

The CI/CD runs in an ephemeral Docker container, so there are no credentials stored. I can however add secrets in GitLab, but I don't know what git command I would use to log in to GitHub pragmatically.

I have tried git push https://usesrname:password@github.com/myrepo but that gives me an Authentication failed error.

Any ideas?

PrestonDocks
  • 215
  • 3
  • 11

1 Answers1

4

You should create a new personal access token for your CI pipeline. Just go to https://github.com/settings/tokens to create it. You need to give the repo scope to the new token.

Then you can use https://<username>:<token>@github.com/myrepo to push.

Note: That token is dangerous, it allows full control to your repos just like your password.

vaizki
  • 256
  • 1
  • 2
  • Thank you. I am going to add the username and password to GitLab secrets, so it won't be shown, even in the CI logs. – PrestonDocks Dec 13 '21 at 22:04
  • @vaizki seems like this has been deprecated `Support for password authentication was removed on August 13, 2021` – Peter Feb 28 '23 at 10:45