Skip to content
Snippets Groups Projects
Commit e583d928 authored by Kwangjin Lee's avatar Kwangjin Lee
Browse files

Update .gitlab-ci.yml file

parent 0f057e3b
No related branches found
No related tags found
1 merge request!367test publish build
Pipeline #245566 passed
image: python:3.10-bullseye
stages:
- test
- build
- deploy
......@@ -13,39 +12,85 @@ cache:
- .cache/pip
- venv/
# Before running other jobs, setup Python
before_script:
- python -V
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install -r requirements.txt
# This job tests if the book compiles gracefully after a new addition
test-build:
stage: test
build-draft:
stage: build
script:
- echo "Building draft version"
- teachbooks build book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
artifacts:
paths:
- book/_build/html
- stdout.log
- stderr.log
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"
- if: $CI_COMMIT_BRANCH == "publish" && $CI_PIPELINE_SOURCE == "push"
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
when: always
build-production:
stage: build
script:
- echo "Building production version"
- teachbooks build --publish book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
artifacts:
paths:
- book/_build/html
- stdout.log
- stderr.log
rules:
- if: $CI_COMMIT_BRANCH == "publish"
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "publish"
when: always
deploy-draft:
stage: deploy
needs: ["build-draft"]
script:
- pip install -r requirements.txt
- jupyter-book clean book/
- jupyter-book build book/
# This job commits the built HTML to the publish-html branch
# push-html:
# stage: deploy
# only:
# - publish
# before_script:
# - apt-get update -y
# - apt-get install rsync -y
# - git config --global user.name "$GITLAB_USER_NAME"
# - git config --global user.email "$GITLAB_USER_EMAIL"
# - git fetch origin publish-html
# - git checkout publish-html
# script:
# - rsync -av --delete-after --exclude=".git/" --exclude=".cache/" --exclude="venv/" ./book/_build/html/ .
# - git add --all -- ':!.cache/*'
# - git commit --allow-empty -m "$CI_COMMIT_MESSAGE"
# - git push https://gitlab-ci-token:$ACCESS_TOKEN@gitlab.tudelft.nl/$CI_PROJECT_PATH.git publish-html
- |
curl -X POST https://mude.citg.tudelft.nl/hooks/book-deploy-draft \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \
-d '{
"object_kind": "pipeline",
"object_attributes": {
"status": "success",
"ref": "main"
}
}'
environment:
name: draft
url: https://mude.citg.tudelft.nl/2024/book/draft
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
when: always
deploy-production:
stage: deploy
needs: ["build-production"]
script:
- |
curl -X POST https://mude.citg.tudelft.nl/hooks/book-deploy \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \
-d '{
"object_kind": "pipeline",
"object_attributes": {
"status": "success",
"ref": "publish"
}
}'
environment:
name: production
url: https://mude.citg.tudelft.nl/2024/book
rules:
- if: $CI_COMMIT_BRANCH == "publish"
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "publish"
when: always
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment