@@ -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
@@ -49,18 +64,14 @@ jobs:
steps :
- name : Checkout
uses : actions/checkout@v4
- name : Set up Environment
uses : pnpm/action-setup@v4
with :
version : 10
run_install : |
- recursive: true
args: [--frozen-lockfile, --prefer-offline]
- name : Set up Node.js
uses : actions/setup-node@v4
with :
node_version : 20
cache : ' pnpm'
- name : Enable pnpm
run : corepack enable && corepack prepare pnpm@10.2.0 --activate
- name : Install dependencies
run : pnpm install --frozen-lockfile --prefer-offline --ignore-scripts --no-color
- name : Lint
run : pnpm lint
@@ -76,18 +87,14 @@ jobs:
steps :
- name : Checkout
uses : actions/checkout@v4
- name : Set up Environment
uses : pnpm/action-setup@v4
with :
version : 10
run_install : |
- recursive: true
args: [--frozen-lockfile, --prefer-offline]
- name : Set up Node.js
uses : actions/setup-node@v4
with :
node_version : 20
cache : ' pnpm'
- name : Enable pnpm
run : corepack enable && corepack prepare pnpm@10.2.0 --activate
- name : Install dependencies
run : pnpm install --frozen-lockfile --prefer-offline --ignore-scripts --no-color
- name : Test
run : pnpm test
@@ -103,18 +110,14 @@ jobs:
steps :
- name : Checkout
uses : actions/checkout@v4
- name : Set up Environment
uses : pnpm/action-setup@v4
with :
version : 10
run_install : |
- recursive: true
args: [--frozen-lockfile, --prefer-offline]
- name : Set up Node.js
uses : actions/setup-node@v4
with :
node_version : 20
cache : ' pnpm'
- name : Enable pnpm
run : corepack enable && corepack prepare pnpm@10.2.0 --activate
- name : Install dependencies
run : pnpm install --frozen-lockfile --prefer-offline --ignore-scripts --no-color
- name : Build
run : pnpm build
@@ -133,24 +136,16 @@ jobs:
uses : actions/checkout@v4
with :
fetch-depth : 0
- name : Set up Environment
uses : pnpm/action-setup@v4
with :
version : 10
run_install : |
- recursive: true
args: [--frozen-lockfile, --prefer-offline]
- name : Set up Node.js
uses : actions/setup-node@v4
with :
node_version : 20
cache : ' pnpm'
- name : Enable pnpm
run : corepack enable && corepack prepare pnpm@10.2.0 --activate
- name : Install dependencies
run : pnpm install --frozen-lockfile --prefer-offline --ignore-scripts --no-color
- name : 🏷️ Sync Versions (if Tagged)
run : pnpm sync-versions
- name : 🏷️ Release Packages (Tag-Driven)
run : |
echo "🏷️ Tag detected [${{ github.ref_name }}], performing sync release..."