Skip to content

Commit bbe1e23

Browse files
committed
fix: Force cancel previous runs
1 parent 61a9d73 commit bbe1e23

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

.github/workflows/deploy-and-e2e.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Deploy & run E2E
2-
run-name: 'E2E by ${{ github.event.client_payload.actor || github.actor }} to ${{ github.event.client_payload.stack || github.event.inputs.stack }} (core: ${{ github.event.client_payload.core-image-tag || inputs.core-image-tag }}, farajaland: ${{ github.event.client_payload.countryconfig-image-tag || inputs.countryconfig-image-tag }}) ${{ github.event.client_payload.runtime || inputs.runtime }}'
2+
run-name: 'E2E by ${{ github.event.client_payload.actor || github.actor }} to ${{ github.event.client_payload.stack || github.event.inputs.stack }} (core: ${{ github.event.client_payload.core-image-tag || inputs.core-image-tag }}, farajaland: ${{ github.event.client_payload.countryconfig-image-tag || inputs.countryconfig-image-tag }})'
33
on:
44
repository_dispatch:
55
types: [run_e2e]
@@ -43,14 +43,39 @@ on:
4343
required: false
4444
default: false
4545
type: boolean
46-
concurrency:
47-
group: ${{ github.event.client_payload.stack || inputs.stack }}
48-
cancel-in-progress: true
46+
# concurrency:
47+
# group: ${{ github.event.client_payload.stack || inputs.stack }}
48+
# cancel-in-progress: true
4949

5050
jobs:
51+
cancel-in-progress-runs:
52+
name: Cancel in-progress runs
53+
runs-on: ubuntu-24.04
54+
steps:
55+
- name: Cancel in-progress runs
56+
env:
57+
GH_TOKEN: ${{ github.token }}
58+
STACK_NAME: ${{ github.event.client_payload.stack || inputs.stack }}
59+
CURRENT_RUN_ID: ${{ github.run_id }}
60+
run: |
61+
# FIXME: Replace with ${{ github.workflow_id }}
62+
gh api "/repos/${{ github.repository }}/actions/workflows/116693890/runs?status=in_progress&status=queued" \
63+
--jq '.workflow_runs[] | select(.id != '$CURRENT_RUN_ID') | .id' > /tmp/run_ids.txt
64+
cat /tmp/run_ids.txt
65+
while read -r run_id; do
66+
RUN_NAME=$(gh api "/repos/${{ github.repository }}/actions/runs/$run_id" --jq '.name')
67+
[[ "$RUN_NAME" != *"to $STACK_NAME"* ]] && echo "Skip $RUN_NAME" && continue
68+
echo "Cancelling run: $run_id"
69+
gh api --method POST "/repos/${{ github.repository }}/actions/runs/$run_id/cancel"
70+
gh api \
71+
--method POST \
72+
/repos/opencrvs/e2e/actions/runs/${run_id}/force-cancel
73+
echo
74+
echo "Workflow $RUN_NAME cancelled: https://github.com/opencrvs/e2e/actions/runs/${run_id}"
75+
done < /tmp/run_ids.txt
5176
debug:
5277
name: Debug output
53-
runs-on: ubuntu-22.04
78+
runs-on: ubuntu-24.04
5479
outputs:
5580
runtime: ${{ steps.runtime.outputs.runtime }}
5681
domain: ${{ steps.runtime.outputs.domain }}
@@ -124,7 +149,7 @@ jobs:
124149
command: npx playwright install --with-deps
125150

126151
deploy-docker:
127-
needs: debug
152+
needs: [debug, cancel-in-progress-runs]
128153
if: needs.debug.outputs.runtime == 'docker'
129154
uses: ./.github/workflows/deploy.yml
130155
with:

0 commit comments

Comments
 (0)