Skip to content

Instantly share code, notes, and snippets.

@calvinchengx
Last active May 20, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvinchengx/d91245d65fd8ed424203d5d725946a95 to your computer and use it in GitHub Desktop.
Save calvinchengx/d91245d65fd8ed424203d5d725946a95 to your computer and use it in GitHub Desktop.
direct deployment to git repo
version: 2
jobs:
build:
machine: true
steps:
- run:
name: Clone repo
working_directory: ~/workdir
command: |
git clone --depth 1 https://${REPO_GITHUB_TOKEN}@github.com/namespace/repo.git
- deploy:
name: Trigger repo deployment
working_directory: ~/workdir/repo
command: |
git config credential.helper 'cache --timeout=120'
git config user.email "<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://${REPO_GITHUB_TOKEN}@github.com/namespace/repo.git master
# The git clone is first.
# All subsequent git commands have to be executed in the clone directory. working_directory simplifies this a great deal.
# The token REPO_GITHUB_TOKEN is a personal access token with repo scope for the target repository.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment