Skip to content

Instantly share code, notes, and snippets.

@JLNNN JLNNN/.gitlab-ci.yml
Created Aug 14, 2019

Embed
What would you like to do?
GitLab Continuous Delivery Pipeline -> Deployment to Webserver (SSH) (without Composer)
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
You can’t perform that action at this time.