Update .gitlab-ci.yml

parent acbdad72
variables:
REVIEW_IMAGE: docker.rz.tu-harburg.de:5000/docker/nginx--review-apps:latest
BUILD_IMAGE: docker.rz.tu-harburg.de:5000/docker/gitbook-itbh-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/gitbook:node
stages:
- setup
- test
- build
- review
- deploy
review:pdf:
stage: review
only:
- branches
when: manual
retry: 2
tags:
- development
script:
- pwd
- mkdir -p book_pdf; sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} pdf ./ ./book_pdf/book.pdf
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
- clean
- linkchecker
before_script:
# 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:
- book_pdf
except:
- master
review:start:
stage: review
retry: 2
- node_modules
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 ./_book/. ${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
except:
- master
- gitbook install
test:
stage: test
script:
#- 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 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
pdf:
stage: build
script:
- gitbook install
- mkdir -p book_pdf
- gitbook pdf ./ ./book_pdf/book.pdf
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules
- book_pdf
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
paths:
- book_pdf
pages:branches:
stage: build
script:
- 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'
- gitbook install
- gitbook build
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules
- _book
artifacts:
paths:
- _book
except:
- master
pages:master:
stage: build
script:
- 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'
- gitbook install
- gitbook build
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules
- _book
artifacts:
paths:
- _book
only:
- 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}"
- 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
environment:
name: $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
variables:
GIT_STRATEGY: none
script:
- sudo docker stop ${DOCKER_CONTAINER_NAME}
when: manual
environment:
name: review/${CI_COMMIT_REF_NAME}
action: stop
only:
- branches
tags:
- development
- ssg
except:
- master
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
environment:
name: $CI_COMMIT_REF_NAME
action: stop
deploy:
stage: deploy
only:
- master
retry: 2
tags:
- ssg
except:
- schedules
script:
- pwd
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} install
- sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} build
- mkdir -p book_pdf; sudo docker run --rm -v $(pwd):/source ${BUILD_IMAGE} pdf ./ ./book_pdf/book.pdf
- 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 _book/* "${SSH_USER}"@"${HOST_NAME}":/usr/share/nginx/html/production
- sshpass -p "${SSH_PASSWD}" scp -P "${SSH_PORT}" -r book_pdf "${SSH_USER}"@"${HOST_NAME}":/usr/share/nginx/html/production
- 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: production
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/
\ No newline at end of file
url: https://$PROXY_HOST_NAME/${BASE_DIR}/
#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
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