Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.12 KiB
Newer Older
image: ruby:3.2.2-bookworm
Kwangjin Lee's avatar
Kwangjin Lee committed
stages:
Kwangjin Lee's avatar
Kwangjin Lee committed
  - build
Kwangjin Lee's avatar
Kwangjin Lee committed
  - deploy
Kwangjin Lee's avatar
Kwangjin Lee committed
variables:
  LC_ALL: C.UTF-8
build-page:
Kwangjin Lee's avatar
Kwangjin Lee committed
  stage: build
Kwangjin Lee's avatar
Kwangjin Lee committed
    JEKYLL_ENV: ${{ CI_COMMIT_BRANCH == "release" && "production" || "development" }}
  before_script:
    - gem install bundler
    - bundle install
    - chmod +x ./build-page.sh
Kwangjin Lee's avatar
Kwangjin Lee committed
  script:
Kwangjin Lee's avatar
Kwangjin Lee committed
      if [ "$CI_COMMIT_BRANCH" == "release" ]; then
        echo "Running on release branch"
        ./build-page.sh "/" true
      elif [ "$CI_COMMIT_BRANCH" == "main" ]; then
        echo "Running on main branch"
        ./build-page.sh "/2024/draft" false
Kwangjin Lee's avatar
Kwangjin Lee committed
      else
        echo "Running on other branches"
        ./build-page.sh "/draft" false
Kwangjin Lee's avatar
Kwangjin Lee committed
  artifacts:
    paths:
Kwangjin Lee's avatar
Kwangjin Lee committed
  rules:
Kwangjin Lee's avatar
Kwangjin Lee committed
    - if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "release"
    - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "release"
Kwangjin Lee's avatar
Kwangjin Lee committed
      when: always
Kwangjin Lee's avatar
Kwangjin Lee committed

deploy-draft:
  stage: deploy
  needs: ["build-page"]
Kwangjin Lee's avatar
Kwangjin Lee committed
  script:
    - |
      curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy-draft \
Kwangjin Lee's avatar
Kwangjin Lee committed
        -H "Content-Type: application/json" \
        -H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \
Kwangjin Lee's avatar
Kwangjin Lee committed
        -d '{
          "object_kind": "pipeline",
          "object_attributes": {
            "status": "success",
            "ref": "main"
Kwangjin Lee's avatar
Kwangjin Lee committed
        }'
  environment:
    name: draft
    url: https://mude.citg.tudelft.nl/2024/draft
Kwangjin Lee's avatar
Kwangjin Lee committed
  rules:
    - if: $CI_COMMIT_BRANCH == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"
      when: always
Kwangjin Lee's avatar
Kwangjin Lee committed

deploy-production:
Kwangjin Lee's avatar
Kwangjin Lee committed
  stage: deploy
  needs: ["build-page"]
Kwangjin Lee's avatar
Kwangjin Lee committed
  script:
    - |
      curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy \
Kwangjin Lee's avatar
Kwangjin Lee committed
        -H "Content-Type: application/json" \
        -H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \
Kwangjin Lee's avatar
Kwangjin Lee committed
        -d '{
          "object_kind": "pipeline",
          "object_attributes": {
            "status": "success",
Kwangjin Lee's avatar
Kwangjin Lee committed
            "ref": "release"
Kwangjin Lee's avatar
Kwangjin Lee committed
  environment:
    name: production
    url: https://mude.citg.tudelft.nl/2024
Kwangjin Lee's avatar
Kwangjin Lee committed
  rules:
Kwangjin Lee's avatar
Kwangjin Lee committed
    - if: $CI_COMMIT_BRANCH == "release" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "release"
      when: always