Skip to content

Instantly share code, notes, and snippets.

@pablodgonzalez
Created September 1, 2020 22:04
Show Gist options
  • Save pablodgonzalez/edc2afcd80eb5b4e49a7b3cc4c5850b2 to your computer and use it in GitHub Desktop.
Save pablodgonzalez/edc2afcd80eb5b4e49a7b3cc4c5850b2 to your computer and use it in GitHub Desktop.
GitLab CI - SSH with Passphrase deploy example
before_script:
- apt-get update -y && apt-get install openssh-client rsync -y
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo 'echo "$SSH_PASSPHRASE"' > ~/.ssh/.print_ssh_password
- chmod 700 ~/.ssh/.print_ssh_password
- chmod +x ~/.ssh/.print_ssh_password
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | DISPLAY=":0.0" SSH_ASKPASS=~/.ssh/.print_ssh_password setsid ssh-add - > /dev/null
deploy_staging:
type: deploy
script:
- rsync -rzvhWP --delete --delete-excluded --exclude-from 'exclude-files.txt' ./public/ [email protected]:~/public/
- echo "Staging Ready!"
environment:
name: staging
url: http://www.host.net
only:
- development
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment