Skip to content

Instantly share code, notes, and snippets.

@anilnautiyal
Last active March 15, 2018 12:32
Show Gist options
  • Save anilnautiyal/a75cc36476d24054fcb4358a653bb3b9 to your computer and use it in GitHub Desktop.
Save anilnautiyal/a75cc36476d24054fcb4358a653bb3b9 to your computer and use it in GitHub Desktop.
.gitlab-ci.yml
before_script:
- apt-get update -yqq
- 'which ssh-agent || ( apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
stages:
- deploy_dev
- deploy_stage
- deploy_master
Deploy Dev:
stage: deploy_dev
script:
- ssh-add <(echo "$DEVPKEY")
- ssh $DEVUSER@$DEVHOST "cd $DEVPATH && git pull origin dev"
only:
- dev
Deploy Stage:
stage: deploy_stage
script:
- ssh-add <(echo "$STAGEPKEY")
- ssh $STAGEUSER@$STAGEHOST "cd $STAGEPATH && git pull origin staging"
only:
- staging
Deploy Master:
stage: deploy_master
script:
- ssh-add <(echo "$MASTERPKEY")
- ssh $MASTERUSER@$MASTERHOST "cd $MASTERPATH && git pull origin master"
only:
- master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment