Commit bfc5d416 authored by Andreas Böttger's avatar Andreas Böttger 😬

Update .gitlab-ci.yml

parent a48b4d34
Pipeline #67370 passed with stages
in 4 minutes and 38 seconds
......@@ -6,9 +6,11 @@ variables:
stages:
- setup
- test
- pages
- review
- deploy
- clean
- linkchecker
before_script:
# https://docs.gitlab.com/ee/ci/ssh_keys/README.html
......@@ -21,7 +23,7 @@ before_script:
prepare:
stage: setup
cache:
key: gems
key: "$CI_COMMIT_REF_SLUG"
paths:
- vendor/bundle
script:
......@@ -30,43 +32,50 @@ prepare:
test:
stage: test
script:
- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "/$ENV{''CI_PROJECT_PATH''}/~$ENV{''CI_COMMIT_REF_NAME''}/"\n!g'' _config.yml'
- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "$ENV{''REVIEW_BASE_DIR''}/~$ENV{''CI_COMMIT_REF_NAME''}/"\n!g'' _config.yml'
- cat _config.yml
- bundle install
- bundle exec jekyll build -d test
cache:
key: gems
key: "$CI_COMMIT_REF_SLUG"
paths:
- vendor/bundle
policy: pull
except:
- master
review:pages:
stage: pages
script:
- bundle install
- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "$ENV{''REVIEW_BASE_DIR''}/~$ENV{''CI_COMMIT_REF_NAME''}/"\n!g'' _config.yml'
- cat _config.yml
- bundle exec jekyll build -d public
except:
- master
artifacts:
paths:
- public
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- vendor/bundle
policy: pull
review:start:
stage: review
script:
- 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}/
url: https://${REVIEW_PROXY_HOST_NAME}/${REVIEW_BASE_DIR}/~${CI_COMMIT_REF_NAME}/
on_stop: review:stop
......@@ -84,65 +93,47 @@ review:stop:
environment:
name: $CI_COMMIT_REF_NAME
action: stop
deploy:
stage: deploy
pages:
stage: pages
only:
- 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
# Wenn `url: https://$PROXY_HOST_NAME/` verwendet wird,
# dann wird `$ENV{''BASE_DIR''}/~$ENV{''CI_COMMIT_REF_NAME''}` NICHT
# benötigt
- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "$ENV{''BASE_DIR''}"\n!g'' _config.yml'
#- 'perl -i -pe ''s!.*baseurl:\s.*!baseurl: "/"\n!g'' _config.yml'
- cat _config.yml
- 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"
artifacts:
paths:
- public
cache:
key: gems
key: "$CI_COMMIT_REF_SLUG"
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/
policy: pull
deploy:on-schedule:
deploy:
stage: deploy
only:
- 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/
name: $CI_COMMIT_REF_NAME
url: https://$PROXY_HOST_NAME$BASE_DIR
#url: https://$PROXY_HOST_NAME/
clean:
stage: clean
script:
......@@ -157,44 +148,26 @@ clean:
environment:
name: $CI_COMMIT_REF_NAME
action: stop
.deploy:
stage: deploy
only:
- master
except:
- schedules
tags:
- ssg
script:
- pwd
# `_layouts/home.html` kann datumsabhängig mit einer Datei aus `backlogs` überschrieben werden
- 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")}}'
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} install
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} build
# Da `StrictHostKeyChecking no` verwendet wird, ist das Folgende ok :\
- ssh-keygen -f "$HOME/.ssh/known_hosts" -R [@$HOST_NAME]:$SSH_PORT
- sshpass -p "$SSH_PASSWD" ssh -p "$SSH_PORT" $SSH_USER@$HOST_NAME "mkdir -p /usr/share/nginx/html/production"
- sshpass -p "$SSH_PASSWD" scp -P "$SSH_PORT" -r _site/* $SSH_USER@$HOST_NAME:/usr/share/nginx/html/production
environment:
name: production
url: https://$PROXY_HOST_NAME/
.deploy:on-schedule:
stage: deploy
only:
- schedules
tags:
- ssg
script:
- pwd
# `_layouts/home.html` kann datumsabhängig mit einer Datei aus `backlogs` überschrieben werden
- 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")}}'
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} install
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} build
- sshpass -p "$SSH_PASSWD" ssh -p "$SSH_PORT" $SSH_USER@$HOST_NAME "mkdir -p /usr/share/nginx/html/production"
- sshpass -p "$SSH_PASSWD" scp -P "$SSH_PORT" -r _site/* $SSH_USER@$HOST_NAME:/usr/share/nginx/html/production
environment:
name: production
url: https://$PROXY_HOST_NAME/
\ No newline at end of file
linkchecker:intern:
stage: linkchecker
except:
- master
image:
name: linkchecker/linkchecker
entrypoint: [""]
script:
- linkchecker --recursion-level 10 --threads 10 --no-status --no-robots --no-warnings --ignore-url 'https://fonts.gstatic.com/{0,1}$' https://${REVIEW_PROXY_HOST_NAME}/${REVIEW_BASE_DIR}/~${CI_COMMIT_REF_NAME}/
when: manual
linkchecker:all:
stage: linkchecker
except:
- master
image:
name: linkchecker/linkchecker
entrypoint: [""]
script:
- linkchecker --recursion-level 10 --threads 10 --no-status --no-robots --no-warnings --check-extern --ignore-url 'https://fonts.gstatic.com/{0,1}$' https://${REVIEW_PROXY_HOST_NAME}/${REVIEW_BASE_DIR}/~${CI_COMMIT_REF_NAME}/
when: manual
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