@@ -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_prog res s/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" == ref s/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