...
 
Commits (4)
image: ruby:2.4
variables:
JEKYLL_ENV: production
LC_ALL: C.UTF-8
cache:
paths:
- vendor
before_script:
# Ensure ssh-agent is installed
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Ensure rsync is installed
- 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
- bundle install --path=vendor
build:
stage: build
script:
- bundle exec jekyll build
artifacts:
paths:
- _site
deploy:
stage: deploy
dependencies:
- build
only:
refs:
- master
script:
# 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 -
# Create the SSH directory and give it the right permissions
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# Add the public host key for the target server
- echo "$SSH_HOST_KEY" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# Add the SSH config
- echo "$SSH_CONFIG" > ~/.ssh/config
- chmod 644 ~/.ssh/config
# Deploy the artifacts from the build stage
- rsync -a --delete _site/ "$SSH_DEPLOY_DEST"