Commit 2731fc63 authored by mh's avatar mh
Browse files

add deploy step

parent 3cb36172
Pipeline #3695 failed with stages
in 17 seconds
......@@ -3,7 +3,7 @@ default:
stages:
- helper
- build
# - deploy
- deploy
helper:
image: registry.code.immerda.ch/immerda/container-images/buildah/centos:8
stage: helper
......@@ -26,9 +26,50 @@ build:
script:
- bundle exec rake cleanup
- bundle exec rake site
- tar cfz site.tar.gz _site
- mv _site public
- tar cfz site.tar.gz public
artifacts:
paths:
- site.tar.gz
expire_in: 1 day
deploy:
tags:
- container
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/www.immerda.ch
variables:
GIT_STRATEGY: none
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 "${DEPLOY_HOST_FPS}
" > ~/.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
echo "${DEPLOY_HOST_FPS}" | awk '{ print $1 }' | while read -r host; do
lftp -e "mirror -eRv -x ^dev/ public $DEPLOY_SLUG; quit;" -u $DEPLOY_USER,dummy sftp://$host
done
# TODO: Implement clean up: Remove the review dir once the merge to master happened.
Markdown is supported
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