Skip to content

Instantly share code, notes, and snippets.

@anilnautiyal
Last active February 16, 2022 02:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anilnautiyal/47a412907fc08e120a1a6b3ff3146c74 to your computer and use it in GitHub Desktop.
Save anilnautiyal/47a412907fc08e120a1a6b3ff3146c74 to your computer and use it in GitHub Desktop.
.gitlab-ci.yml
before_script:
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- echo "$PRIVATEKEY" | tr -d '\r' | ssh-add - > /dev/null
stages:
- deploy_staging
- deploy_master
Deploy Master:
stage: deploy_master
script:
- git remote add production $production-remote-url
- "git checkout -b master"
- "git push production master:master -f"
only:
- master
Deploy Staging:
stage: deploy_staging
script:
- git remote add staging $staging-remote-url
- "git checkout -b staging"
- "git push staging staging:master -f"
only:
- staging
@khoipro
Copy link

khoipro commented Jun 24, 2019

Thanks for your sharing. I recently updated a full code of this, but worked and tested. Hope someone found it helpful!

https://gist.github.com/khoipro/4df13fe0231d37a9bd8ae5493c6d7f97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment