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

Merge branch 'rztab' into 'master'

Update .gitlab-ci.yml

See merge request !18
parents f1ecd08a fa9c5b53
image: docker.rz.tu-harburg.de:5000/docker/gitbook:node
image: docker.rz.tu-harburg.de:5000/rzt/images/gitbook:node
# https://docs.gitlab.com/ee/ci/yaml/README.html#exclude-jobs-with-rules-from-certain-pipelines
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
stages:
- setup
- test
- build
- review
- deploy
- clean
- setup
- test
- build
- review
- deploy
- clean
- linkchecker
before_script:
# https://docs.gitlab.com/ee/ci/ssh_keys/README.html
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# https://docs.gitlab.com/ee/ci/ssh_keys/README.html
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
setup:
stage: setup
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules
script:
- gitbook install
stage: setup
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules
script:
- gitbook install
test:
stage: test
script:
#- 'if [ -f book.json ]; then perl -i -pe ''s!%base_path%!/$ENV{''CI_PROJECT_PATH''}/reviews/~$ENV{''CI_COMMIT_REF_NAME''}/!g'' book.json; fi'
#- 'if [ -f book.json ]; then perl -i -pe ''s!%pluginsConfig.downloadpdf.base%!/$ENV{''CI_PROJECT_PATH''}/reviews/~$ENV{''CI_COMMIT_REF_NAME''}/book_pdf/book.pdf?/!g'' book.json; fi'
#- if [ -f book.json ]; then jq -r --arg base_path "/${CI_PROJECT_PATH}/~${CI_COMMIT_REF_NAME}/" '.base_path |= $base_path' book.json | sponge book.json; fi
#- if [ -f book.json ]; then jq -r --arg pluginsConfig__downloadpdf_base "/${CI_PROJECT_PATH}/~${CI_COMMIT_REF_NAME}/book_pdf/book.pdf?/" '.pluginsConfig.downloadpdf.base |= $pluginsConfig__downloadpdf_base' book.json | sponge book.json; fi
#- if [ -f book.json ]; then cat book.json; fi
#- 'if [ -f book.json ]; then perl -i -pe ''s!%base_path%!/$ENV{''CI_PROJECT_PATH''}/!g'' book.json; fi'
#- 'if [ -f book.json ]; then perl -i -pe ''s!%pluginsConfig.downloadpdf.base%!/$ENV{''CI_PROJECT_PATH''}/book_pdf/book.pdf?/!g'' book.json; fi'
#- 'if [ -f book.json ]; then cat book.json; fi'
#- if [ -f book.json ]; then jq -r --arg base_path "/${CI_PROJECT_PATH}/" '.base_path |= $base_path' book.json | sponge book.json; fi
#- if [ -f book.json ]; then jq -r --arg pluginsConfig__downloadpdf_base "/${CI_PROJECT_PATH}/book_pdf/book.pdf?/" '.pluginsConfig.downloadpdf.base |= $pluginsConfig__downloadpdf_base' book.json | sponge book.json; fi
#- if [ -f book.json ]; then cat book.json; fi
- exit 0
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules
policy: pull
except:
- master
rules:
- if: '$CI_COMMIT_REF_NAME != "master"'
pdf:
stage: build
......@@ -63,8 +69,8 @@ pdf:
pages:branches:
stage: build
script:
- 'if [ -f book.json ]; then perl -i -pe ''s!%base_path%!/$ENV{''CI_PROJECT_PATH''}/reviews/~$ENV{''CI_COMMIT_REF_NAME''}/!g'' book.json; fi'
- 'if [ -f book.json ]; then perl -i -pe ''s!%pluginsConfig.downloadpdf.base%!/$ENV{''CI_PROJECT_PATH''}/reviews/~$ENV{''CI_COMMIT_REF_NAME''}/book_pdf/book.pdf?/!g'' book.json; fi'
- if [ -f book.json ]; then jq -r --arg base_path "${REVIEW_BASE_DIR}~${CI_COMMIT_REF_NAME}/" '.base_path |= $base_path' book.json | sponge book.json; fi
- if [ -f book.json ]; then jq -r --arg pluginsConfig__downloadpdf_base "${REVIEW_BASE_DIR}~${CI_COMMIT_REF_NAME}/book_pdf/book.pdf?/" '.pluginsConfig.downloadpdf.base |= $pluginsConfig__downloadpdf_base' book.json | sponge book.json; fi
- 'if [ -f book.json ]; then cat book.json; fi'
- gitbook install
- gitbook build
......@@ -76,14 +82,14 @@ pages:branches:
artifacts:
paths:
- _book
except:
- master
rules:
- if: '$CI_COMMIT_REF_NAME != "master"'
pages:master:
stage: build
script:
- 'if [ -f book.json ]; then perl -i -pe ''s!%base_path%!/$ENV{''CI_PROJECT_PATH''}/!g'' book.json; fi'
- 'if [ -f book.json ]; then perl -i -pe ''s!%pluginsConfig.downloadpdf.base%!/$ENV{''CI_PROJECT_PATH''}/book_pdf/book.pdf?/!g'' book.json; fi'
- if [ -f book.json ]; then jq -r --arg base_path "${BASE_DIR}" '.base_path |= $base_path' book.json | sponge book.json; fi
- if [ -f book.json ]; then jq -r --arg pluginsConfig__downloadpdf_base "${BASE_DIR}book_pdf/book.pdf?/" '.pluginsConfig.downloadpdf.base |= $pluginsConfig__downloadpdf_base' book.json | sponge book.json; fi
- 'if [ -f book.json ]; then cat book.json; fi'
- gitbook install
- gitbook build
......@@ -95,80 +101,110 @@ pages:master:
artifacts:
paths:
- _book
only:
- master
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
review:start:
stage: review
script:
- 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}" "mkdir -p /usr/share/nginx/html/~${CI_COMMIT_REF_NAME}"
- scp -P "${REVIEW_SSH_PORT}" -r _book/* "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}":"/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}/book_pdf"
- scp -P "${REVIEW_SSH_PORT}" -r book_pdf/* "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}":"/usr/share/nginx/html/~${CI_COMMIT_REF_NAME}/book_pdf"
- if [ -d book_pdf ]; then ssh -p "${REVIEW_SSH_PORT}" "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}" "mkdir -p /usr/share/nginx/html/~${CI_COMMIT_REF_NAME}/book_pdf"; fi
- if [ -d book_pdf ]; then scp -P "${REVIEW_SSH_PORT}" -r book_pdf/* "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}":"/usr/share/nginx/html/~${CI_COMMIT_REF_NAME}/book_pdf"; fi
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- _book
- book_pdf
policy: pull
except:
- master
rules:
- if: '$CI_COMMIT_REF_NAME != "master"'
environment:
name: $CI_COMMIT_REF_NAME
url: https://$REVIEW_PROXY_HOST_NAME/${CI_PROJECT_PATH}/reviews/~${CI_COMMIT_REF_NAME}/
url: https://${REVIEW_PROXY_HOST_NAME}${REVIEW_BASE_DIR}~${CI_COMMIT_REF_NAME}/
on_stop: review:stop
review:stop:
stage: review
script:
- 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
rules:
- if: '$CI_COMMIT_REF_NAME != "master"'
when: manual
allow_failure: true
environment:
name: $CI_COMMIT_REF_NAME
action: stop
deploy:
stage: deploy
only:
- master
except:
- schedules
script:
- 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 _book/* "${SSH_USER}"@"${HOST_NAME}":"/usr/share/nginx/html"
- ssh -p "${SSH_PORT}" "${SSH_USER}"@"${HOST_NAME}" "mkdir -p /usr/share/nginx/html/book_pdf"
- scp -P "${SSH_PORT}" -r book_pdf/* "${SSH_USER}"@"${HOST_NAME}":"/usr/share/nginx/html/book_pdf"
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- _book
- book_pdf
policy: pull
environment:
name: _$CI_COMMIT_REF_NAME
#url: http://$HOST_NAME$COLON$HTTP_PORT/production/
#url: https://$PROXY_HOST_NAME/$BASE_PATH/
#url: https://$PROXY_HOST_NAME/$CI_PROJECT_PATH/
url: https://oerientation.rz.tuhh.de/
stage: deploy
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
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}" "mkdir -p /usr/share/nginx/html"
- scp -P "${SSH_PORT}" -r _book/* "${SSH_USER}"@"${HOST_NAME}":"/usr/share/nginx/html"
- if [ -d book_pdf ]; then ssh -p "${SSH_PORT}" "${SSH_USER}"@"${HOST_NAME}" "mkdir -p /usr/share/nginx/html/book_pdf"; fi
- if [ -d book_pdf ]; then scp -P "${SSH_PORT}" -r book_pdf/* "${SSH_USER}"@"${HOST_NAME}":"/usr/share/nginx/html/book_pdf"; fi
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- _book
- book_pdf
policy: pull
environment:
name: $CI_COMMIT_REF_NAME
url: https://$PROXY_HOST_NAME${BASE_DIR}
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
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
when: manual
allow_failure: true
environment:
name: $CI_COMMIT_REF_NAME
action: stop
linkchecker:intern:
stage: linkchecker
rules:
- if: '$CI_COMMIT_REF_NAME != "master"'
when: manual
allow_failure: true
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}/
linkchecker:all:
stage: linkchecker
rules:
- if: '$CI_COMMIT_REF_NAME != "master"'
when: manual
allow_failure: true
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}/
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