Skip to content
Snippets Groups Projects
Commit f0bd8d84 authored by Robert Lanzafame's avatar Robert Lanzafame
Browse files

Merge branch 'revert-0d58cc48' into 'main'

Revert "Update .gitlab-ci.yml file"

See merge request !5
parents 0d58cc48 4c552027
No related branches found
No related tags found
2 merge requests!10merge for publish,!5Revert "Update .gitlab-ci.yml file"
Pipeline #245690 passed
image: python:3.10-bullseye image: ruby:3.2.2-bookworm
stages: stages:
- build - build
- deploy - deploy
variables: variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" LC_ALL: C.UTF-8
cache: build-page:
paths:
- .cache/pip
- venv/
before_script:
- python -V
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install -r requirements.txt
- apt-get update && apt-get install -y jq # Install jq
build-book:
stage: build stage: build
variables:
JEKYLL_ENV: ${{ CI_COMMIT_BRANCH == "publish" && "production" || "development" }}
before_script:
- gem install bundler
- bundle install
- chmod +x ./build-page.sh
script: script:
- | - |
if [ "$CI_COMMIT_BRANCH" == "publish" ]; then if [ "$CI_COMMIT_BRANCH" == "publish" ]; then
echo "Building production version" echo "Running on publish branch"
teachbooks build --publish book/ > >(tee stdout.log) 2> >(tee stderr.log >&2) ./build-page.sh "/" true
elif [ "$CI_COMMIT_BRANCH" == "main" ]; then
echo "Running on main branch"
./build-page.sh "/2024/draft" false
else else
echo "Building draft version" echo "Running on other branches"
teachbooks build book/ > >(tee stdout.log) 2> >(tee stderr.log >&2) ./build-page.sh "/draft" false
fi fi
artifacts: artifacts:
paths: paths:
- book/_build/html - public
- stdout.log
- stderr.log
expire_in: 1 week
rules: rules:
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "publish" - if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "publish"
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "publish" - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "publish"
...@@ -44,46 +37,44 @@ build-book: ...@@ -44,46 +37,44 @@ build-book:
deploy-draft: deploy-draft:
stage: deploy stage: deploy
needs: ["build-book"] needs: ["build-page"]
script: script:
- | - |
BUILD_JOB_ID=$(curl -s -H "PRIVATE-TOKEN: $CI_JOB_TOKEN" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs?scope[]=success" | jq '.[] | select(.name=="build-book") | .id') curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy-draft \
curl -X POST https://mude.citg.tudelft.nl/hooks/book-deploy-draft \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \ -H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \
-d '{ -d '{
"object_kind": "pipeline", "object_kind": "pipeline",
"object_attributes": { "object_attributes": {
"status": "success", "status": "success",
"ref": "main" "ref": "main"
}, }
"build_job_id": "'$BUILD_JOB_ID'"
}' }'
environment: environment:
name: draft name: draft
url: https://mude.citg.tudelft.nl/2024/book/draft url: https://mude.citg.tudelft.nl/2024/draft
rules: rules:
- if: $CI_COMMIT_BRANCH == "main" - if: $CI_COMMIT_BRANCH == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
when: always
deploy-production: deploy-production:
stage: deploy stage: deploy
needs: ["build-book"] needs: ["build-page"]
script: script:
- | - |
BUILD_JOB_ID=$(curl -s -H "PRIVATE-TOKEN: $CI_JOB_TOKEN" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs?scope[]=success" | jq '.[] | select(.name=="build-book") | .id') curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy \
curl -X POST https://mude.citg.tudelft.nl/hooks/book-deploy-production \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \ -H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \
-d '{ -d '{
"object_kind": "pipeline", "object_kind": "pipeline",
"object_attributes": { "object_attributes": {
"status": "success", "status": "success",
"ref": "publish" "ref": "publish"
}, }
"build_job_id": "'$BUILD_JOB_ID'"
}' }'
environment: environment:
name: production name: production
url: https://mude.citg.tudelft.nl/2024/book url: https://mude.citg.tudelft.nl/2024
rules: rules:
- if: $CI_COMMIT_BRANCH == "publish" - if: $CI_COMMIT_BRANCH == "publish" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "publish"
\ No newline at end of file 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