Created
September 1, 2020 22:04
-
-
Save pablodgonzalez/edc2afcd80eb5b4e49a7b3cc4c5850b2 to your computer and use it in GitHub Desktop.
GitLab CI - SSH with Passphrase deploy example
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 -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