This post somehow acts as a test to check whether the CI/CD pipeline on gitlab is working. The following file does the magic.
- Starting a docker container with node-lts
- Setup needed ssh files and known hosts
- Build the gatsby site
- Copies the content of ‘public’ to the server via rsync
image: node:lts
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
paths:
- node_modules/
build:
stage: build
only:
- master
before_script:
# first check and install all dependencies
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
# prepare ssh
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- yarn install
- ./node_modules/.bin/gatsby build
- cd public
- rsync -avz -e "ssh" * $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH
Next I should do something with layout and styling ;)