When executing a build for git repository giantswarm/docs-content
in CircleCI, I\'d like to push a commit to another repository giantswarm/docs
.
Thanks to the hint by Ali Amin I now have this working solution:
version: 2
jobs:
build:
machine: true
steps:
- run:
name: Clone docs
working_directory: ~/workdir
command: |
git clone --depth 1 https://${DOCS_GITHUB_TOKEN}@github.com/giantswarm/docs.git
- deploy:
name: Trigger docs deployment
working_directory: ~/workdir/docs
command: |
git config credential.helper 'cache --timeout=120'
git config user.email ""
git config user.name "Deployment Bot"
git commit --allow-empty -m "Trigger deployment"
# Push quietly to prevent showing the token in log
git push -q https://${DOCS_GITHUB_TOKEN}@github.com/giantswarm/docs.git master
Some notes:
git clone
is first.git
commands have to be executed in the clone directory. working_directory
simplifies this a great deal.DOCS_GITHUB_TOKEN
is a personal access token with repo
scope for the target repository.