A simple way is to generate a personal access token instead.

We can generate a token through this url https://github.com/settings/tokens/new?scopes=repo,admin:repo_hook. Modify the scopes to make sure it will only do the limit actions.

And then, we may get string seems like 9927d2878ffa105fc5236c762f2fd7zfd28b841d.

If we wish to push a few commits to your repository. Instead of

git push git@github.com:org-name/project-name.git

We can use this command:

git push https://9927d2878ffa105fc5236c762f2fd7zfd28b841d@github.com/org-name/project-name.git

If we are running in a ci. A simple way is to set 9927d2878ffa105fc5236c762f2fd7zfd28b841d as a environment variable. Let's name it as "GH_TOKEN".

We can write

git push https://$GH_TOKEN@github.com/org-name/project-name.git

in our CI scripts.

Categories: Code

Yu

Ideals are like the stars: we never reach them, but like the mariners of the sea, we chart our course by them.

Leave a Reply

Your email address will not be published. Required fields are marked *