Created
August 14, 2019 11:06
-
-
Save JLNNN/888b9317942bc1aa16fb4935b58b211e to your computer and use it in GitHub Desktop.
GitLab Continuous Delivery Pipeline -> Deployment to Webserver (SSH) (without Composer)
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: | |
- apt-get update -yqq | |
- apt-get install -yqq git | |
- 'which ssh-agent || ( apt-get install -qq openssh-client )' | |
- mkdir -p ~/.ssh | |
- eval $(ssh-agent -s) | |
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' | |
stages: | |
- deploy | |
deploy:staging: | |
stage: deploy | |
environment: | |
name: staging | |
url: $QA_DOMAIN | |
script: | |
- echo "Deploy to staging (QA) server" | |
- ssh-add <(echo "$QA_SSH_PRIVATE_KEY") | |
- ssh $QA_SERVER_USER@$QA_SERVER_HOST "cd $QA_WEB_ROOT && git reset --hard && git checkout develop && git pull origin develop && exit" | |
only: | |
- develop | |
deploy:prod: | |
stage: deploy | |
environment: | |
name: production | |
url: $PROD_DOMAIN | |
script: | |
- echo "Deploy to production server" | |
- ssh-add <(echo "$PROD_SSH_PRIVATE_KEY") | |
- ssh $PROD_SERVER_USER@$PROD_SERVER_HOST "cd $PROD_WEB_ROOT && git reset --hard && git checkout master && git pull origin master && exit" | |
only: | |
- master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment