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:
- build
- deploy
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
LC_ALL: C.UTF-8
cache:
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:
build-page:
stage: build
variables:
JEKYLL_ENV: ${{ CI_COMMIT_BRANCH == "publish" && "production" || "development" }}
before_script:
- gem install bundler
- bundle install
- chmod +x ./build-page.sh
script:
- |
if [ "$CI_COMMIT_BRANCH" == "publish" ]; then
echo "Building production version"
teachbooks build --publish book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
echo "Running on publish branch"
./build-page.sh "/" true
elif [ "$CI_COMMIT_BRANCH" == "main" ]; then
echo "Running on main branch"
./build-page.sh "/2024/draft" false
else
echo "Building draft version"
teachbooks build book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
echo "Running on other branches"
./build-page.sh "/draft" false
fi
artifacts:
paths:
- book/_build/html
- stdout.log
- stderr.log
expire_in: 1 week
- public
rules:
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "publish"
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "publish"
......@@ -44,46 +37,44 @@ build-book:
deploy-draft:
stage: deploy
needs: ["build-book"]
needs: ["build-page"]
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/book-deploy-draft \
curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy-draft \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \
-H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \
-d '{
"object_kind": "pipeline",
"object_attributes": {
"status": "success",
"ref": "main"
},
"build_job_id": "'$BUILD_JOB_ID'"
}
}'
environment:
name: draft
url: https://mude.citg.tudelft.nl/2024/book/draft
url: https://mude.citg.tudelft.nl/2024/draft
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_BRANCH == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
when: always
deploy-production:
stage: deploy
needs: ["build-book"]
needs: ["build-page"]
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/book-deploy-production \
curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \
-H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \
-d '{
"object_kind": "pipeline",
"object_attributes": {
"status": "success",
"ref": "publish"
},
"build_job_id": "'$BUILD_JOB_ID'"
}
}'
environment:
name: production
url: https://mude.citg.tudelft.nl/2024/book
url: https://mude.citg.tudelft.nl/2024
rules:
- if: $CI_COMMIT_BRANCH == "publish"
\ No newline at end of file
- if: $CI_COMMIT_BRANCH == "publish" || $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