Commit 92673806 authored by Marius DAVID's avatar Marius DAVID
Browse files

Move file to accomodate new CI

parents 1c25d062 a9b9de9e
Loading
Loading
Loading
Loading
Loading
+25 −23
Original line number Diff line number Diff line
# See https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml

include:
    - 'https://gitlab.com/Cynerd/gitlab-ci-nix/-/raw/master/template.yml'
  - local: .gitlab/build-year.yml
    inputs:
      year: 2025
    rules:
      - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  - local: .gitlab/build-year.yml
    inputs:
      year: 2024
    rules:
      - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

stages:
  - build
  - comment

variables:
  NIX_CACHE_HOME: "./nix-cache"

build:
  extends: .nix
  image: python:3-alpine
  stage: build
  rules:
    - if: $CI_PIPELINE_SOURCE == $CI_PIPELINE_SOURCE # Truly terrible syntax (otherwise, won’t run during MR as a side effect of the rule in comment )
  stage: "build"
  cache:
    key: nix-user-cache
    paths:
      - nix-cache
    - when: always
  script:
    - NIX_CACHE_HOME=$(pwd)/nix-cache
    - "nix run --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs/25.05#python3 -- ./tools/merge_data.py ./entries atlas2024.json"
    - "nix run --extra-experimental-features nix-command --extra-experimental-features flakes nixpkgs/25.05#python3 -- ./tools/merge_data.py ./entries2025 atlas2025.json"
    - python ./tools/merge_data.py ./entries/2024 ./atlas2024.json
    - python ./tools/merge_data.py ./entries/2025 ./atlas2025.json
  artifacts:
    expire_in: "1 year"
    expire_in: "1 hour"
    expose_as: "atlas_json"
    paths:
      - "atlas2024.json"
      - "atlas2025.json"

comment:
  extends: .nix
  image: alpine
  stage: "comment"
  rules:
    - if: "$CI_PIPELINE_SOURCE == 'merge_request_event'"
  cache:
    key: nix-user-cache
    paths:
      - nix-cache
  dependencies:
    - build
  needs:
    - build
  before_script:
    - apk add curl jq
  script:
    # Here are the comments that will always be added
    # - DOCUMENTATION="Did you update the corresponding documentation?"
    # Here we parse them into URL
    # - DOCUMENTATION_PARSED=$(echo $DOCUMENTATION | sed 's/ /%20/g')
    - NIX_CACHE_HOME=$(pwd)/nix-cache
    - ATLAS2024_JSON_URL=$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/refs/merge-requests/$CI_MERGE_REQUEST_IID/head/raw/atlas2024.json?job=build
    - ATLAS2025_JSON_URL=$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/refs/merge-requests/$CI_MERGE_REQUEST_IID/head/raw/atlas2025.json?job=build
    - BODY="You can preview the data [here for 2024](https://atlas.mariusdavid.fr?atlas=$(nix --extra-experimental-features nix-command --extra-experimental-features flakes run nixpkgs/25.05#urlencode -- $ATLAS2024_JSON_URL)) and [here for 2025](https://atlas2025.mariusdavid.fr?atlas=$(nix --extra-experimental-features nix-command --extra-experimental-features flakes run nixpkgs/25.05#urlencode -- $ATLAS2025_JSON_URL))."
    - BODY="You can preview the data [here for 2024](https://2024.canvas-atlas.fediverse.events?atlas=$(jq -rn --arg x "$ATLAS2024_JSON_URL" '$x|@uri')) and [here for 2025](https://2025.canvas-atlas.fediverse.events?atlas=$(jq -rn --arg x "$ATLAS2025_JSON_URL" '$x|@uri'))."
    - echo $BODY
    # And finally we post them on your merge request!
    - 'curl --request POST --header "PRIVATE-TOKEN: ${GITLAB_CI_COMMENT_API_KEY}" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes" --data-urlencode "body=$BODY"'
    - 'curl --fail --request POST --header "PRIVATE-TOKEN: ${GITLAB_CI_COMMENT_API_KEY}" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes" --data-urlencode "body=$BODY"'

.gitlab/build-year.yml

0 → 100644
+41 −0
Original line number Diff line number Diff line
spec:
  inputs:
    year:
      type: string
---
build $[[ inputs.year ]]:
  image: python:3-alpine
  stage: build
  before_script:
    - apk add git git-lfs
  script:
    - git lfs install && git lfs pull
    - mkdir -p ./web/atlas
    - python ./tools/merge_data.py ./entries/$[[ inputs.year ]] ./web/atlas/$[[ inputs.year ]].json
    - python ./tools/pre_process.py $[[ inputs.year ]] ./web
    - rm -f ./web/index_template.html
  artifacts:
    expire_in: 1 hour
    expose_as: atlas_$[[ inputs.year ]]
    paths:
      - ./web

deploy $[[ inputs.year ]]:
  image: alpine
  stage: deploy
  dependencies:
    - build $[[ inputs.year ]]
  needs:
    - build $[[ inputs.year ]]
  before_script:
    - apk add curl zip
  script:
    - |
      # 📁 Creating zip
      zip -r archive.zip web
    - |
      # ✨ Send artifact to deployer
      curl -X POST --fail-with-body \
      -H "Authorization: Bearer $DEPLOY_KEY_$[[ inputs.year ]]" \
      -F "file=@archive.zip" \
      -s -o /dev/null -w "Deploy Status: %{http_code}" --fail https://deploy.sc07.company/deploy
+0 −0

File moved.

Loading