Skip to content

Instantly share code, notes, and snippets.

@halimarm
Created April 21, 2021 07:44
Show Gist options
  • Save halimarm/d9bd50cf8f944899f9d7c7247066ed37 to your computer and use it in GitHub Desktop.
Save halimarm/d9bd50cf8f944899f9d7c7247066ed37 to your computer and use it in GitHub Desktop.
Deploy with ssh
before_script:
- apt-get update -qq
- apt-get install -qq git
# Setup SSH deploy keys
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
deploy_staging:
type: deploy
environment:
name: staging
url: example.com
script:
- ssh root@example.com "cd var/www/ && 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