How to push a commit to Github from a CircleCI build using a personal access token

后端 未结 3 1438
旧巷少年郎
旧巷少年郎 2021-02-07 09:32

When executing a build for git repository giantswarm/docs-content in CircleCI, I\'d like to push a commit to another repository giantswarm/docs.

<
3条回答
  •  后悔当初
    2021-02-07 10:16

    Although embedding the token into the command works for this case it might not work for all cases and doesn't answer the question.

    1. Other cases would include scripts that dont expose direct access to the git command. They rely on the GH_TOKEN variable being set and you wouldn't be able to inject it as in the example.

    2. It doesn't answer the question:

    Any idea why it doesn't on CircleCI?

    On CircleCI support forum there is an answer about this:

    https://support.circleci.com/hc/en-us/articles/360018860473-How-to-push-a-commit-back-to-the-same-repository-as-part-of-the-CircleCI-job

    Running git push results in "ERROR: The key you are authenticating with has been marked as read only."

    The deploy key that the project is configured with, by default when you add a project on CircleCI, only has read access, so a key with write permissions needs to be configured to be used, to avoid the above error message. Please ensure that a user key or a read-write deployment key has been configured for the project

    https://circleci.com/docs/2.0/gh-bb-integration/#creating-a-github-deploy-key

    After going through this process you should have a deploy key with write permissions that allows the push.

提交回复
热议问题