diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index ca315e9..e178f94 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -29,28 +29,34 @@ jobs: run: | echo "๐Ÿ”Ž Debug: Event=$EVENT, Ref=$REF, RefName=$REF_NAME, RunId=$RUN_ID" - if [[ "$REF" == refs/tags/v* ]]; then - echo "๐Ÿš€ Release detected ($REF_NAME). Cancelling non-tag runs..." - - # Fetch all runs - RUNS=$(curl -s -H "Authorization: token $GITEA_TOKEN" "https://git.infra.mintel.me/api/v1/repos/$REPO/actions/runs") - - # Identify runs to cancel: in_progress/queued, NOT this run, and NOT a tag run - echo "$RUNS" | jq -c '.workflow_runs[] | select(.status == "in_progress" or .status == "queued") | select(.id | tostring != "'$RUN_ID'")' | while read -r run; do - ID=$(echo "$run" | jq -r '.id') - RUN_REF=$(echo "$run" | jq -r '.ref') - TITLE=$(echo "$run" | jq -r '.display_title') + case "$REF" in + refs/tags/v*) + echo "๐Ÿš€ Release detected ($REF_NAME). Cancelling non-tag runs..." - if [[ "$RUN_REF" != refs/tags/v* ]]; then - echo "๐Ÿ›‘ Cancelling redundant branch run $ID ($TITLE) on $RUN_REF..." - curl -X POST -s -H "Authorization: token $GITEA_TOKEN" "https://git.infra.mintel.me/api/v1/repos/$REPO/actions/runs/$ID/cancel" - else - echo "โญ๏ธ Skipping parallel release run $ID ($TITLE) on $RUN_REF" - fi - done - else - echo "โ„น๏ธ Regular push. No prioritazation needed." - fi + # Fetch all runs + RUNS=$(curl -s -H "Authorization: token $GITEA_TOKEN" "https://git.infra.mintel.me/api/v1/repos/$REPO/actions/runs") + + # Identify runs to cancel: in_progress/queued, NOT this run, and NOT a tag run + echo "$RUNS" | jq -c '.workflow_runs[] | select(.status == "in_progress" or .status == "queued") | select(.id | tostring != "'$RUN_ID'")' | while read -r run; do + ID=$(echo "$run" | jq -r '.id') + RUN_REF=$(echo "$run" | jq -r '.ref') + TITLE=$(echo "$run" | jq -r '.display_title') + + case "$RUN_REF" in + refs/tags/v*) + echo "โญ๏ธ Skipping parallel release run $ID ($TITLE) on $RUN_REF" + ;; + *) + echo "๐Ÿ›‘ Cancelling redundant branch run $ID ($TITLE) on $RUN_REF..." + curl -X POST -s -H "Authorization: token $GITEA_TOKEN" "https://git.infra.mintel.me/api/v1/repos/$REPO/actions/runs/$ID/cancel" + ;; + esac + done + ;; + *) + echo "โ„น๏ธ Regular push. No prioritization needed." + ;; + esac lint: name: ๐Ÿงน Lint