在 CircleCI 中为 git 存储库 giantswarm/docs-content
执行构建时,我想将提交推送到另一个存储库 giantswarm/docs
。
我在 circle.yml
的 deployment
部分有这个:
git config credential.helper cache
git config user.email "<some verified email>"
git config user.name "Github Bot"
git clone --depth 1 https://${GITHUB_PERSONAL_TOKEN}:x-oauth-basic@github.com/giantswarm/docs.git
cd docs/
git commit --allow-empty -m "Trigger build and publishing via docs-content"
git push -u origin master
这fails在带有此错误消息的最后一个命令中:
ERROR: The key you are authenticating with has been marked as read only.
fatal: Could not read from remote repository.
GITHUB_PERSONAL_TOKEN
环境变量设置为用户的个人访问 token ,该 token 是在 repo
范围内创建的,用于访问私有(private)仓库 giantswarm/docs
。此外,我将该用户添加到对该存储库具有管理员权限的团队。
当我在新的 Ubuntu VM 中执行这一系列命令时,它工作得很好。知道为什么它不在 CircleCI 上吗?
最佳答案
我用过
git push -q https://${GITHUB_PERSONAL_TOKEN}@github.com/<user>/<repo>.git master
它奏效了。 更新为:
# Push changes
git config credential.helper 'cache --timeout=120'
git config user.email "<email>"
git config user.name "<user-name>"
git add .
git commit -m "Update via CircleCI"
# Push quietly to prevent showing the token in log
git push -q https://${GITHUB_PERSONAL_TOKEN}@github.com/giantswarm/docs.git master
关于git - 如何使用个人访问 token 从 CircleCI 构建推送到 Github 的提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44773415/