Last active
February 16, 2022 02:13
-
-
Save anilnautiyal/47a412907fc08e120a1a6b3ff3146c74 to your computer and use it in GitHub Desktop.
.gitlab-ci.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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