Commit 983ed8b3 authored by Andreas Böttger's avatar Andreas Böttger 😬

bigger, better, faster

parent 92e4a717
Pipeline #26453 failed with stages
variables:
REVIEW_IMAGE: docker.rz.tu-harburg.de:5000/docker/nginx--review-apps:latest
BUILD_IMAGE: docker.rz.tu-harburg.de:5000/docker/jekyll-hoou-glr:latest
DOCKER_CONTAINER_NAME: ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG}
before_script:
- sudo docker pull ${BUILD_IMAGE}
- sudo docker pull ${REVIEW_IMAGE}
image: docker.rz.tu-harburg.de:5000/docker/ruby:latest
variables:
JEKYLL_ENV: production
stages:
- setup
- test
- review
- deploy
- clean
before_script:
# https://docs.gitlab.com/ee/ci/ssh_keys/README.html
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- export LC_ALL="C.UTF-8"; export LANG="en_US.UTF-8"; export LANGUAGE="en_US.UTF-8"
- export BUNDLE_PATH="vendor/bundle"
prepare:
stage: setup
cache:
key: gems
paths:
- vendor/bundle
script:
- bundle install
test:
stage: test
script:
- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "/$ENV{''CI_PROJECT_PATH''}/~$ENV{''CI_COMMIT_REF_NAME''}/"\n!g'' _config.yml'
- cat _config.yml
- bundle exec jekyll build -d test
cache:
key: gems
paths:
- vendor/bundle
policy: pull
except:
- master
review:start:
stage: review
retry: 2
script:
- pwd
- sudo docker run --detach --rm --env VIRTUAL_HOST=${CI_ENVIRONMENT_SLUG} --name ${DOCKER_CONTAINER_NAME} ${REVIEW_IMAGE} || true
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} install
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} build
- sudo docker cp ./_site/. ${DOCKER_CONTAINER_NAME}:/usr/share/nginx/html
- if [ ! -z "${REVIEW_CREDENTIALS}" ]; then mkdir -p ./nginx && echo "${REVIEW_CREDENTIALS}" > ./nginx/credentials && sudo docker cp ./nginx/credentials ${DOCKER_CONTAINER_NAME}:/etc/nginx/htpasswd/credentials; rm -f ./nginx/credentials; fi
environment:
name: review/${CI_COMMIT_REF_NAME}
url: http://${CI_ENVIRONMENT_SLUG}.collaborating.tuhh.de
on_stop: review:stop
only:
- branches
tags:
- development
- ssg
- echo "$REVIEW_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "/$ENV{''CI_PROJECT_PATH''}/~$ENV{''CI_COMMIT_REF_NAME''}/"\n!g'' _config.yml'
- cat _config.yml
- bundle install
- bundle exec jekyll build -d public
- eval $(ssh-agent -s)
- echo "$REVIEW_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- ssh -p "${REVIEW_SSH_PORT}" "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}" "mkdir -p /usr/share/nginx/html/~${CI_COMMIT_REF_NAME}"
- scp -P "${REVIEW_SSH_PORT}" -r public/* "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}":"/usr/share/nginx/html/~${CI_COMMIT_REF_NAME}"
cache:
key: gems
paths:
- vendor/bundle
policy: pull
artifacts:
paths:
- public
except:
- master
environment:
name: $CI_COMMIT_REF_NAME
url: https://$REVIEW_PROXY_HOST_NAME/${CI_PROJECT_PATH}/~${CI_COMMIT_REF_NAME}/
on_stop: review:stop
review:stop:
stage: review
variables:
GIT_STRATEGY: none
script:
- sudo docker stop ${DOCKER_CONTAINER_NAME}
- echo "$REVIEW_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$REVIEW_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- ssh -p "${REVIEW_SSH_PORT}" "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}" "rm -rf /usr/share/nginx/html/~${CI_COMMIT_REF_NAME}"
when: manual
except:
- master
environment:
name: review/${CI_COMMIT_REF_NAME}
name: $CI_COMMIT_REF_NAME
action: stop
deploy:
stage: deploy
only:
- branches
tags:
- development
- ssg
- master
except:
- schedules
script:
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
#- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "/$ENV{''CI_PROJECT_PATH''}"\n!g'' _config.yml'
#- cat _config.yml
- find backlog -regextype egrep -regex "backlog/[0-9]{8,8}_.*" | sort | awk -F'/|_' -v date=$(date +%Y%m%d) '{if ($2 <= date) {print("cp backlog/"$2"_home.html _layouts/home.html"); system("cp backlog/"$2"_home.html _layouts/home.html")}}'
- bundle install
- bundle exec jekyll build -d public
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- ssh -p "${SSH_PORT}" "${SSH_USER}"@"${HOST_NAME}" "mkdir -p /usr/share/nginx/html"
- scp -P "${SSH_PORT}" -r public/* "${SSH_USER}"@"${HOST_NAME}":"/usr/share/nginx/html"
cache:
key: gems
paths:
- vendor/bundle
policy: pull
environment:
name: _$CI_COMMIT_REF_NAME
#url: http://$HOST_NAME$COLON$HTTP_PORT/
#url: https://$PROXY_HOST_NAME/$BASE_PATH/
url: https://$PROXY_HOST_NAME/$CI_PROJECT_PATH/
#url: https://$PROXY_HOST_NAME/
deploy:on-schedule:
stage: deploy
only:
- schedules
script:
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
#- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "/$ENV{''CI_PROJECT_PATH''}"\n!g'' _config.yml'
#- cat _config.yml
- find backlog -regextype egrep -regex "backlog/[0-9]{8,8}_.*" | sort | awk -F'/|_' -v date=$(date +%Y%m%d) '{if ($2 <= date) {print("cp backlog/"$2"_home.html _layouts/home.html"); system("cp backlog/"$2"_home.html _layouts/home.html")}}'
- bundle install
- bundle exec jekyll build -d public
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- ssh -p "${SSH_PORT}" "${SSH_USER}"@"${HOST_NAME}" "mkdir -p /usr/share/nginx/html"
- scp -P "${SSH_PORT}" -r public/* "${SSH_USER}"@"${HOST_NAME}":"/usr/share/nginx/html"
cache:
key: gems
paths:
- vendor/bundle
policy: pull
environment:
name: _$CI_COMMIT_REF_NAME
#url: http://$HOST_NAME$COLON$HTTP_PORT/
#url: https://$PROXY_HOST_NAME/$BASE_PATH/
url: https://$PROXY_HOST_NAME/$CI_PROJECT_PATH/
#url: https://$PROXY_HOST_NAME/
clean:
stage: clean
script:
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- ssh -p "${SSH_PORT}" "${SSH_USER}"@"${HOST_NAME}" "rm -rf /usr/share/nginx/html/*"
when: manual
only:
- master
environment:
name: $CI_COMMIT_REF_NAME
action: stop
deploy:
.deploy:
stage: deploy
only:
- master
......@@ -74,7 +181,7 @@ deploy:
name: production
url: https://$PROXY_HOST_NAME/
deploy:on-schedule:
.deploy:on-schedule:
stage: deploy
only:
- schedules
......
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