default:
  images: alpine:latest

stages:
  - commit
  - pages

add-commit:
  rules:
    - if: $CI_PIPELINE_SOURCE == "trigger"
    - if: $CI_PIPELINE_SOURCE == "web"
  stage: commit
  before_script:
    - apk add curl
  script:
    - echo "test" >> test.tsv
    - PRIVATE_TOKEN_HEADER='PRIVATE-TOKEN:'
    - curl --request PUT --header "$PRIVATE_TOKEN_HEADER $CIPRIVATETOKEN" \
     --header "Content-Type: application/json" \
     --data "{\"branch\": \"main\", \"author_email\": \"author@example.com\", \"author_name\": \"Ms C. I. Pipeline\", \"content\": \"$(cat test.tsv)\", \"commit_message\": \"update test.tsv\"}" \
     "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/repository/files/test%2Etsv"

pages:
  rules:
    - if: $CI_PIPELINE_SOURCE == "commit"
  stage: pages
  script:
    - echo "TODO"