fix(pipeline): use POSIX sh compatible logic for release prioritization
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧹 Lint (push) Successful in 44s
Monorepo Pipeline / 🧪 Test (push) Successful in 40s
Monorepo Pipeline / 🏗️ Build (push) Successful in 1m47s
Monorepo Pipeline / 🚀 Release (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been cancelled
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧹 Lint (push) Successful in 44s
Monorepo Pipeline / 🧪 Test (push) Successful in 40s
Monorepo Pipeline / 🏗️ Build (push) Successful in 1m47s
Monorepo Pipeline / 🚀 Release (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been cancelled
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been cancelled
This commit is contained in:
@@ -29,28 +29,34 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "🔎 Debug: Event=$EVENT, Ref=$REF, RefName=$REF_NAME, RunId=$RUN_ID"
|
echo "🔎 Debug: Event=$EVENT, Ref=$REF, RefName=$REF_NAME, RunId=$RUN_ID"
|
||||||
|
|
||||||
if [[ "$REF" == refs/tags/v* ]]; then
|
case "$REF" in
|
||||||
echo "🚀 Release detected ($REF_NAME). Cancelling non-tag runs..."
|
refs/tags/v*)
|
||||||
|
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
|
# Fetch all runs
|
||||||
echo "🛑 Cancelling redundant branch run $ID ($TITLE) on $RUN_REF..."
|
RUNS=$(curl -s -H "Authorization: token $GITEA_TOKEN" "https://git.infra.mintel.me/api/v1/repos/$REPO/actions/runs")
|
||||||
curl -X POST -s -H "Authorization: token $GITEA_TOKEN" "https://git.infra.mintel.me/api/v1/repos/$REPO/actions/runs/$ID/cancel"
|
|
||||||
else
|
# Identify runs to cancel: in_progress/queued, NOT this run, and NOT a tag run
|
||||||
echo "⏭️ Skipping parallel release run $ID ($TITLE) on $RUN_REF"
|
echo "$RUNS" | jq -c '.workflow_runs[] | select(.status == "in_progress" or .status == "queued") | select(.id | tostring != "'$RUN_ID'")' | while read -r run; do
|
||||||
fi
|
ID=$(echo "$run" | jq -r '.id')
|
||||||
done
|
RUN_REF=$(echo "$run" | jq -r '.ref')
|
||||||
else
|
TITLE=$(echo "$run" | jq -r '.display_title')
|
||||||
echo "ℹ️ Regular push. No prioritazation needed."
|
|
||||||
fi
|
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:
|
lint:
|
||||||
name: 🧹 Lint
|
name: 🧹 Lint
|
||||||
|
|||||||
Reference in New Issue
Block a user