Update .gitlab-ci.yml file

This commit is contained in:
Kwangjin Lee 2024-07-12 12:43:04 +02:00
parent 589333305b
commit 8e10d35ac9

View file

@ -14,10 +14,10 @@ cache:
paths:
- .cache/pip
# This job tests if the book compiles gracefully after a new addition
test-build:
stage: test
image: continuumio/miniconda3
tags:
- Textbook runner
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
script:
@ -25,10 +25,10 @@ test-build:
- jupyter-book clean book/
- jupyter-book build book/
# This job builds the Docker container
build-book:
stage: build
image: docker
tags:
- Textbook runner
rules:
- if: $CI_COMMIT_BRANCH == "publish" && $CI_PIPELINE_SOURCE == "push"
variables:
@ -36,41 +36,38 @@ build-book:
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"
variables:
TAG: $TAG_DRAFT
before_script:
- docker info
script:
- if [ "$TAG" = "$TAG_LATEST" ]; then sed --in-place=".bak" '/# START DRAFT/,/# END DRAFT/{//!d}' book/_config.yml; fi
# You might need to adjust or remove these Docker commands depending on the runner's capabilities
- 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
tags:
- Textbook runner
rules:
- if: $CI_COMMIT_BRANCH == "publish" && $CI_PIPELINE_SOURCE == "push"
before_script:
- docker info
- docker stop $CI_PROJECT_NAME || exit_code=$?
- if [ $exit_code -ne 0 ]; then echo "Container not found, cannot stop"; else docker rm $CI_PROJECT_NAME; fi
script:
- docker run -d --restart always -p 8000:8000 --name $CI_PROJECT_NAME $TAG_LATEST # Make sure to use a different port for each book!
# These Docker commands might need to be adjusted or replaced
- docker stop $CI_PROJECT_NAME || true
- docker rm $CI_PROJECT_NAME || true
- docker run -d --restart always -p 8000:8000 --name $CI_PROJECT_NAME $TAG_LATEST
environment:
name: production
url: https://interactivetextbooks.citg.tudelft.nl/jupyter-book-manual
# Deploy the draft version of the book
deploy-draft:
stage: deploy
image: docker
tags:
- Textbook runner
rules:
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"
before_script:
- docker info
- docker stop $CI_PROJECT_NAME-draft || exit_code=$?
- if [ $exit_code -ne 0 ]; then echo "Container not found, cannot stop"; else docker rm $CI_PROJECT_NAME-draft; fi
script:
# These Docker commands might need to be adjusted or replaced
- docker stop $CI_PROJECT_NAME-draft || true
- docker rm $CI_PROJECT_NAME-draft || true
- 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