Commit d5b0cbe3 authored by Andreas Böttger's avatar Andreas Böttger 😬
Browse files

Update .gitlab-ci.yml

parent bc3b41a4
Pipeline #67367 passed with stages
in 4 minutes and 23 seconds
...@@ -6,9 +6,11 @@ variables: ...@@ -6,9 +6,11 @@ variables:
stages: stages:
- setup - setup
- test - test
- pages
- review - review
- deploy - deploy
- clean - clean
- linkchecker
before_script: before_script:
# https://docs.gitlab.com/ee/ci/ssh_keys/README.html # https://docs.gitlab.com/ee/ci/ssh_keys/README.html
...@@ -21,7 +23,7 @@ before_script: ...@@ -21,7 +23,7 @@ before_script:
prepare: prepare:
stage: setup stage: setup
cache: cache:
key: gems key: "$CI_COMMIT_REF_SLUG"
paths: paths:
- vendor/bundle - vendor/bundle
script: script:
...@@ -30,43 +32,50 @@ prepare: ...@@ -30,43 +32,50 @@ prepare:
test: test:
stage: test stage: test
script: 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 - cat _config.yml
- bundle install
- bundle exec jekyll build -d test - bundle exec jekyll build -d test
cache: cache:
key: gems key: "$CI_COMMIT_REF_SLUG"
paths: paths:
- vendor/bundle - vendor/bundle
policy: pull policy: pull
except: except:
- master - 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: review:start:
stage: review stage: review
script: script:
- echo "$REVIEW_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts - echo "$REVIEW_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.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) - eval $(ssh-agent -s)
- echo "$REVIEW_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - 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}" - 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}" - 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: except:
- master - master
environment: environment:
name: $CI_COMMIT_REF_NAME 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 on_stop: review:stop
...@@ -84,65 +93,47 @@ review:stop: ...@@ -84,65 +93,47 @@ review:stop:
environment: environment:
name: $CI_COMMIT_REF_NAME name: $CI_COMMIT_REF_NAME
action: stop action: stop
deploy: pages:
stage: deploy stage: pages
only: only:
- master - master
except:
- schedules
script: 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 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 - bundle exec jekyll build -d public
- eval $(ssh-agent -s) artifacts:
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null paths:
- ssh -p "${SSH_PORT}" "${SSH_USER}"@"${HOST_NAME}" "mkdir -p /usr/share/nginx/html" - public
- scp -P "${SSH_PORT}" -r public/* "${SSH_USER}"@"${HOST_NAME}":"/usr/share/nginx/html"
cache: cache:
key: gems key: "$CI_COMMIT_REF_SLUG"
paths: paths:
- vendor/bundle - vendor/bundle
policy: pull 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: deploy:
stage: deploy stage: deploy
only: only:
- master
except:
- schedules - schedules
script: script:
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.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) - eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - 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" - 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" - scp -P "${SSH_PORT}" -r public/* "${SSH_USER}"@"${HOST_NAME}":"/usr/share/nginx/html"
cache:
key: gems
paths:
- vendor/bundle
policy: pull
environment: environment:
name: _$CI_COMMIT_REF_NAME name: $CI_COMMIT_REF_NAME
#url: http://$HOST_NAME$COLON$HTTP_PORT/ url: https://$PROXY_HOST_NAME$BASE_DIR
#url: https://$PROXY_HOST_NAME/$BASE_PATH/ #url: https://$PROXY_HOST_NAME/
#url: https://$PROXY_HOST_NAME/$CI_PROJECT_PATH/
url: https://$PROXY_HOST_NAME/
clean: clean:
stage: clean stage: clean
script: script:
...@@ -157,44 +148,26 @@ clean: ...@@ -157,44 +148,26 @@ clean:
environment: environment:
name: $CI_COMMIT_REF_NAME name: $CI_COMMIT_REF_NAME
action: stop 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: linkchecker:intern:
stage: deploy stage: linkchecker
only: except:
- schedules - master
tags: image:
- ssg name: linkchecker/linkchecker
script: entrypoint: [""]
- pwd script:
# `_layouts/home.html` kann datumsabhängig mit einer Datei aus `backlogs` überschrieben werden - 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}/
- 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")}}' when: manual
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} install
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} build linkchecker:all:
- sshpass -p "$SSH_PASSWD" ssh -p "$SSH_PORT" $SSH_USER@$HOST_NAME "mkdir -p /usr/share/nginx/html/production" stage: linkchecker
- sshpass -p "$SSH_PASSWD" scp -P "$SSH_PORT" -r _site/* $SSH_USER@$HOST_NAME:/usr/share/nginx/html/production except:
environment: - master
name: production image:
url: https://$PROXY_HOST_NAME/ name: linkchecker/linkchecker
\ No newline at end of file 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