Created
October 30, 2019 18:55
-
-
Save kobeumut/f4de7e1c2853687e05c355cc78e6ab32 to your computer and use it in GitHub Desktop.
deploy rails with ssh
This file contains 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 -qq | |
- apt-get install -qq git | |
## | |
## Install ssh-agent if not already installed, it is required by Docker. | |
## (change apt-get to yum if you use an RPM-based image) | |
## | |
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )' | |
## | |
## Run ssh-agent (inside the build environment) | |
## | |
- eval $(ssh-agent -s) | |
## | |
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store | |
## We're using tr to fix line endings which makes ed25519 keys work | |
## without extra base64 encoding. | |
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556 | |
## | |
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null | |
## | |
## Create the SSH directory and give it the right permissions | |
## | |
- mkdir -p ~/.ssh | |
- chmod 700 ~/.ssh | |
## | |
## Use ssh-keyscan to scan the keys of your private server. Replace gitlab.com | |
## with your own domain name. You can copy and repeat that command if you have | |
## more than one server to connect to. | |
## | |
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts | |
- chmod 644 ~/.ssh/known_hosts | |
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' | |
deploy_staging: | |
type: deploy | |
script: | |
- ssh [email protected] "cd ~/elazigbelediyesi/ && git checkout template1 && git pull origin template1 && | |
rbenv sudo rails s -p 80 -b 0.0.0.0 -d && exit" | |
only: | |
- template1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment