Update .gitlab-ci.yml file

This commit is contained in:
Kwangjin Lee 2024-10-02 16:14:24 +02:00
parent faf4727282
commit 51beb38ad4

View file

@ -2,18 +2,15 @@ stages:
- test
- build
- deploy
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
REGISTRY_HOST: localhost:5000
TAG_LATEST: $REGISTRY_HOST/$CI_PROJECT_NAME/$CI_COMMIT_REF_NAME:latest
TAG_DRAFT: $REGISTRY_HOST/$CI_PROJECT_NAME-draft/$CI_COMMIT_REF_NAME:latest
GIT_SUBMODULE_STRATEGY: recursive # For submodules
cache:
paths:
- .cache/pip
# This job tests if the book compiles gracefully after a new addition
test-build:
stage: test
@ -24,13 +21,12 @@ test-build:
- pip install -r requirements.txt
- jupyter-book clean book/
- jupyter-book build book/
# This job builds the Docker container
build-book:
stage: build
image: docker
rules:
- if: $CI_COMMIT_BRANCH == "publish" && $CI_PIPELINE_SOURCE == "push"
- if: $CI_COMMIT_BRANCH == "release" && $CI_PIPELINE_SOURCE == "push"
variables:
TAG: $TAG_LATEST
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"
@ -42,13 +38,12 @@ build-book:
- if [ "$TAG" = "$TAG_LATEST" ]; then sed --in-place=".bak" '/# START DRAFT/,/# END DRAFT/{//!d}' book/_config.yml; fi
- docker build -t $TAG .
- docker push $TAG
# This job takes down the existing container and starts the new one
deploy-book:
stage: deploy
image: docker
rules:
- if: $CI_COMMIT_BRANCH == "publish" && $CI_PIPELINE_SOURCE == "push"
- if: $CI_COMMIT_BRANCH == "release" && $CI_PIPELINE_SOURCE == "push"
before_script:
- docker info
- docker stop $CI_PROJECT_NAME || exit_code=$?
@ -58,7 +53,6 @@ deploy-book:
environment:
name: production
url: https://interactivetextbooks.citg.tudelft.nl/jupyter-book-manual
# Deploy the draft version of the book
deploy-draft:
stage: deploy
@ -73,4 +67,4 @@ deploy-draft:
- docker run -d --restart always -p 8018:8000 --name $CI_PROJECT_NAME-draft $TAG_DRAFT
environment:
name: draft
url: https://interactivetextbooks.citg.tudelft.nl/jupyter-book-manual-draft
url: https://interactivetextbooks.citg.tudelft.nl/jupyter-book-manual-draft