Skip to content

Instantly share code, notes, and snippets.

@kant312
Created February 11, 2020 12:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kant312/da097ad3f91ecc110792df54a95ed82f to your computer and use it in GitHub Desktop.
Save kant312/da097ad3f91ecc110792df54a95ed82f to your computer and use it in GitHub Desktop.
My ready to go GitLab config to deploy an Eleventy website on a VPS using rsync and ssh
stages:
- build
- deploy
eleventy:
stage: build
image: node:lts-buster
cache:
key: "$CI_JOB_NAME"
paths:
- node_modules/
script:
- npm install
- npm run build
artifacts:
paths:
- dist/
only:
- master
rsync:
stage: deploy
image: instrumentisto/rsync-ssh
script:
- mkdir "${HOME}/.ssh"
- echo "${SSH_HOST_KEY}" > "${HOME}/.ssh/known_hosts"
- echo "${SSH_PRIVATE_KEY}" > "${HOME}/.ssh/id_rsa"
- chmod 700 "${HOME}/.ssh/id_rsa"
- rsync -avH dist/* -e ssh ${SSH_USER}@${SSH_HOST}:${WEBROOT_PATH}
only:
- master
@zomars
Copy link

zomars commented Aug 20, 2020

How do you get your HOME and SSH_HOST_KEY variables?

@kant312
Copy link
Author

kant312 commented Aug 21, 2020

@zomars "HOME" is a system variable that points to the current user's home directory. The other variables can be defined in Gitlab CI/CD Settings, under the variables section. More info here: https://gitlab.com/help/ci/variables/README#variables

@zomars
Copy link

zomars commented Aug 21, 2020

Thank you! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment