Commit eec0a3e5 authored by Jan Kiene's avatar Jan Kiene
Browse files

add authentication via CI token

parent 26c825e3
Loading
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ check-merged-ci-config-is-valid:
  tags:
    - ivas-linux
  variables:
    MERGED_YAML: "merged.yaml"
    BASELINE_YAML: "baseline.yaml"
    MERGED_RESPONSE: "merged.json"
    BASELINE_RESPONSE: "baseline.json"
  parallel:
    matrix:
      - REPO:
@@ -38,25 +38,29 @@ check-merged-ci-config-is-valid:
    # we only want the yaml file, skip LFS files for speedup
    - GIT_LFS_SKIP_SMUDGE=1 git clone -b main --single-branch $repo_url $REPO
    - |
      jq --null-input --arg yaml "$(<$REPO/.gitlab-ci.yml)" '.content=$yaml' \
      | curl --url "https://forge.3gpp.org/rep/api/v4/projects/$project_id/ci/lint?include_merged_yaml=true" \
           --header 'Content-Type: application/json' \
           --output $BASELINE_YAML \
           --data @-
      jq -n --arg yaml "$(<$REPO/.gitlab-ci.yml)" '.content=$yaml' \
      | curl -X POST \
             --url "https://forge.3gpp.org/rep/api/v4/projects/$project_id/ci/lint?include_merged_yaml=true" \
             -H "Content-Type: application/json" \
             -H "JOB-TOKEN: $CI_JOB_TOKEN" \
             --output $BASELINE_RESPONSE \
             --data-binary @-

    - sed -i".bak" "s/\&IVAS_CODEC_CI_REF main/\&IVAS_CODEC_CI_REF ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}/" $REPO/.gitlab-ci.yml
    - |
      jq --null-input --arg yaml "$(<$REPO/.gitlab-ci.yml)" '.content=$yaml' \
      | curl --url "https://forge.3gpp.org/rep/api/v4/projects/$project_id/ci/lint?include_merged_yaml=true" \
           --header 'Content-Type: application/json' \
           --output $MERGED_YAML \
           --data @-
      jq -n --arg yaml "$(<$REPO/.gitlab-ci.yml)" '.content=$yaml' \
      | curl -X POST \
             --url "https://forge.3gpp.org/rep/api/v4/projects/$project_id/ci/lint?include_merged_yaml=true" \
             -H "Content-Type: application/json" \
             -H "JOB-TOKEN: $CI_JOB_TOKEN" \
             --output $MERGED_RESPONSE \
             --data-binary @-
    - |
      grep "\"valid\": true" $MERGED_YAML
      grep "\"valid\": true" $MERGED_RESPONSE
  artifacts:
    when: always
    access: all
    expire_in: "5 days"
    paths:
      - $MERGED_YAML
      - $BASELINE_YAML
      - $MERGED_RESPONSE
      - $BASELINE_RESPONSE