Commit fd0303a7 authored by mh's avatar mh
Browse files

add a first shot of ci integration

parent f95a4946
Pipeline #93 failed
---
image: $CI_REGISTRY/immerda/container-images/hugo-gen:latest
stages:
- build
- deploy
variables:
DEPLOY_BASE: dev/review
DEPLOY_SLUG: dev/review/$CI_PROJECT_NAME/$CI_COMMIT_REF_SLUG
build:
tags:
- container
script:
# Set hugo's 'baseurl' option in case we're not dealing with the master branch.
- 'if ! [ "$CI_COMMIT_REF_SLUG" == "master" ]; then
sed -i "s@^baseURL =.*@baseURL = "http://docs.immerda.ch/$DEPLOY_SLUG@" config.toml;
fi'
- hugo
- tar cfz site.tar.gz public
artifacts:
paths:
- site.tar.gz
expire_in: 1 day
stage:
- build
deploy:
tags:
- container
script:
# Start SSH agent
- eval $(ssh-agent -s)
# Add the SSH key stored in the $PUSH_KEY variable to the agent store
# It is the base64 encoded private key
- echo "$DEPLOY_KEY" | base64 -d | ssh-add - > /dev/null
- mkdir -p --mode=0700 ~/.ssh
- printf "ftp.docs.immerda.ch ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPJx38PfGvaHtkSsHptiHoIQxlI3Yf0cskPNTwAQnY14" > ~/.ssh/known_hosts
- tar fxv site.tar.gz
# In case we're not dealing with the master branch, create the review dir on the webserver.
# We need to catch possible errors, as lftp seems buggy: It fails if the dir already exists,
# even if called with the -f option, which should ignore errors (like this one).
# lftp needs a "dummy" password, even if key-based authentication is used.
- if ! [ "$CI_COMMIT_REF_SLUG" == "master" ];
then DEPLOY_SLUG="www/$DEPLOY_SLUG";
export DEPLOY_SLUG;
lftp -e "mkdir -fp $DEPLOY_SLUG; quit" -u $DEPLOY_USER,dummy sftp://$DEPLOY_HOST || /bin/true;
else
DEPLOY_SLUG="www";
export DEPLOY_SLUG;
fi
- lftp -e "mirror -eRv -x ^dev/ public $DEPLOY_SLUG; quit;" -u $DEPLOY_USER,dummy sftp://$DEPLOY_HOST
# TODO: Implement clean up: Remove the review dir once the merge to master happened.
stage: deploy
# It's currently not possible to use env vars which are / were set in the script: part above.
environment:
name: $DEPLOY_BASE/$CI_PROJECT_NAME/$CI_COMMIT_REF_SLUG
url: https://docs.immerda.ch/$DEPLOY_BASE/$CI_PROJECT_NAME/$CI_COMMIT_REF_SLUG
only:
# This job relies on secret env vars, which are only available in our repo.
- branches@immerda/content/docs.immerda.ch
variables:
GIT_STRATEGY: none
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment