diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 17574168b8903c18ac69202abece844ffb3926f3..28de5650480c12f2bf2a6890cfb6ad256b498255 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,13 +22,19 @@ build-page: - | if [ "$CI_COMMIT_BRANCH" == "publish" ]; then ./build-page.sh "/" true - else + elif [ "$CI_COMMIT_BRANCH" == "main" ]; then ./build-page.sh "/draft" false + else + echo "Branch $CI_COMMIT_BRANCH is not configured for building." + exit 1 fi artifacts: paths: - 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" + when: always deploy-draft: stage: deploy @@ -37,7 +43,7 @@ deploy-draft: - | curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy-draft \ -H "Content-Type: application/json" \ - -H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \ + -H "X-Gitlab-Token: YOUR_SECRET_TOKEN" \ -d '{ "object_kind": "pipeline", "object_attributes": { @@ -59,7 +65,7 @@ deploy-production: - | curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy \ -H "Content-Type: application/json" \ - -H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \ + -H "X-Gitlab-Token: YOUR_SECRET_TOKEN" \ -d '{ "object_kind": "pipeline", "object_attributes": { diff --git a/build-page.sh b/build-page.sh index ba649a3cfe5cfd44ee836a44e4ae4a44cf5b7199..dfd502066ea4894b3a588c6ce99bf14101af59d3 100644 --- a/build-page.sh +++ b/build-page.sh @@ -7,30 +7,15 @@ PAGE_ROOT=$(echo "$PAGE_ROOT" | sed 's:/*$::') if [ "$IS_PUBLISH_DEPLOYMENT" = true ]; then echo "Using publish deployment strategy" - # Remove the banner which identifies the site as a draft - if ! command -v yq &>/dev/null; then - echo "yq could not be found, the draft banner cannot be removed" - echo "Please install yq (with APT or via https://github.com/mikefarah/yq#install) and try again" - else - cp _config.yml _config.yml.bak - yq -i '.is_draft = false' _config.yml - echo "is_draft set to false in _config.yml" - fi + CONFIG_FILE="_config.yml" else echo "Using draft deployment strategy" - # Ensure the draft flag is true for non-publish deployments - if ! command -v yq &>/dev/null; then - echo "yq could not be found, the draft banner cannot be enforced" - echo "Please install yq (with APT or via https://github.com/mikefarah/yq#install) and try again" - else - cp _config.yml _config.yml.bak - yq -i '.is_draft = true' _config.yml - echo "is_draft set to true in _config.yml" - fi + CONFIG_FILE="_config_draft.yml" fi +echo "Using configuration file: $CONFIG_FILE" echo "Publishing to page root: \"$PAGE_ROOT\"" -bundle exec jekyll build -d public -b "$PAGE_ROOT" +bundle exec jekyll build -d public -b "$PAGE_ROOT" --config "$CONFIG_FILE" # Check the build result if [ $? -ne 0 ]; then