diff --git a/.gitea/workflows/pipeline.yml b/.gitea/workflows/pipeline.yml index 16afa35..ca315e9 100644 --- a/.gitea/workflows/pipeline.yml +++ b/.gitea/workflows/pipeline.yml @@ -19,23 +19,38 @@ jobs: image: catthehacker/ubuntu:act-latest steps: - name: ๐Ÿ›‘ Cancel Redundant Runs - if: startsWith(github.ref, 'refs/tags/v') env: GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO: ${{ github.repository }} RUN_ID: ${{ github.run_id }} + REF: ${{ github.ref }} + REF_NAME: ${{ github.ref_name }} + EVENT: ${{ github.event_name }} run: | - echo "๐Ÿš€ Release detected. Cancelling non-tag runs..." - # Get all runs for this repo - RUNS=$(curl -s -H "Authorization: token $GITEA_TOKEN" "https://git.infra.mintel.me/api/v1/repos/$REPO/actions/runs") + echo "๐Ÿ”Ž Debug: Event=$EVENT, Ref=$REF, RefName=$REF_NAME, RunId=$RUN_ID" - # Iterate and cancel in_progress/queued non-tag runs - echo "$RUNS" | jq -c '.workflow_runs[] | select(.status == "in_progress" or .status == "queued") | select(.id | tostring != "'$RUN_ID'") | select(.event != "push" or .ref | contains("refs/tags/v") | not)' | while read run; do - ID=$(echo "$run" | jq -r '.id') - DESC=$(echo "$run" | jq -r '.display_title') - echo "๐Ÿ›‘ Cancelling redundant run $ID ($DESC)..." - curl -X POST -s -H "Authorization: token $GITEA_TOKEN" "https://git.infra.mintel.me/api/v1/repos/$REPO/actions/runs/$ID/cancel" - done + 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') + + 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 lint: name: ๐Ÿงน Lint diff --git a/packages/next-utils/package.json b/packages/next-utils/package.json index 2356d6d..2ff8b2b 100644 --- a/packages/next-utils/package.json +++ b/packages/next-utils/package.json @@ -1,6 +1,6 @@ { "name": "@mintel/next-utils", - "version": "1.7.7", + "version": "1.7.8", "publishConfig": { "access": "public", "registry": "https://npm.infra.mintel.me"