Unblock a stuck deployment
Get new deployments running again when an older workflow run is stuck and holds the deploy job's concurrency group.
The golden path deploy jobs run with cancel-in-progress: false, so only one deploy per environment runs at a time and later runs wait their turn. If a run gets stuck, every later run waits behind it. This can happen to any deploy job, dev or prod. Most often the cause is a fault at GitHub, not your workflow.
Need help?
Ask in #utviklerflyt-support at any point.
Before you begin
- Write access to the application repository. Methods 4 and 5 need permission to push a branch.
- The
ghCLI, logged in with thereposcope. Check withgh auth status.
Preface: Find the stuck run
- Open your repository > Actions and select the deployment workflow.
- Find the oldest run with status Waiting, or a run that has shown the same status for much longer than a deploy takes. Newer runs behind it show Pending.
- Note the run ID from the URL,
https://github.com/OWNER/REPO/actions/runs/RUN_ID. - Note the resolved concurrency group of the stuck job:
dev.concurrencyGrouporprod.concurrencyGroupfromgp-init. For a single-application repository this is the environment name, for examplepirates-prod; for a monorepo it includes the app name, for examplepirates-prod-my-app. Use the actual resolved value rather than constructing it. For prod, it's the same as the GitHub environment name shown on the run.
You can also list waiting runs from the terminal:
End the stuck run
The methods below are ordered by effort. Start with the first one, and stop as soon as the stuck run shows Cancelled or completes. Go to the next method only when the current one fails. If you need deployments running right away, go straight to method 5.
| Method | Move on when you see |
|---|---|
| 1. Approve or reject | No Review deployments button, or “There was a problem approving one of the gates” |
| 2. Cancel in GitHub | The run doesn't change to Cancelled |
| 3. Force-cancel with the API | 409 “Cannot cancel a workflow run that has not been queued yet” |
| 4. Cancel through the concurrency group | The stuck run still shows as waiting a few minutes after the new run started |
| 5. Bypass the run and contact GitHub | Includes a workaround that unblocks deployments |
Method 1: Approve or reject
This method applies only to jobs with environment:, which in the golden path workflows is the prod deploy job. If the run has no Review deployments button, try method 2.
- Open the run and select Review deployments.
- Approve the deployment to let it run, or reject it to end it.
If approving fails with “There was a problem approving one of the gates” or “No pending deployment requests to approve or reject”, the run is stuck at GitHub. Try method 2.
Method 2: Cancel in GitHub
Open the run and select Cancel workflow. If the status doesn't change to Cancelled within a minute, try method 3.
Method 3: Force-cancel with the API
Force-cancel skips the checks a normal cancel waits for. Use the run ID, not a job ID. A job ID gives 404 Not Found.
If GitHub returns 409 “Cannot cancel a workflow run that has not been queued yet”, the run is missing an internal record, which a fault at GitHub can cause. Cancel, approve and reject all depend on that record, so none of them work. Try method 4.
Method 4: Cancel through the concurrency group
A new run in the same concurrency group with cancel-in-progress: true cancels the job that holds the group. This cancel doesn't depend on the record that the stuck run is missing.
Check that no other deploy is running in the group
cancel-in-progress: true cancels whatever holds the group. If a healthy deploy holds it instead of the stuck run, you cancel that deploy partway through.
- Create a branch named
release-concurrency-group. - Add this workflow to the branch. Replace
pirates-prod-my-appwith the group name from step 4 of the preface. For a single-application repository, that's the environment name, for examplepirates-prod.
name: Release concurrency group
on:
push:
branches: [release-concurrency-group]
jobs:
release:
runs-on: ubuntu-latest
concurrency:
group: pirates-prod-my-app # (1)!
cancel-in-progress: true
steps:
- run: echo "Released the concurrency group"
-
Must match the stuck job's group exactly. Don't add an
environment:key, or this job waits for review too. -
Push the branch. The push starts the run.
- Within a minute, check that the stuck run shows Cancelled, and that the new run succeeds.
- Delete the branch.
If the stuck run still shows as waiting a few minutes later, cancel the new run and try method 5.
Method 5: Bypass the run and contact GitHub
This method doesn't end the stuck run. It gives the deploy job a temporary group name so new deployments can run, while GitHub removes the stuck run.
- Add a suffix to the
groupof the stuck deploy job. Change onlyconcurrency.group. Leaveenvironment.nameunchanged, because the AWS role trusts the environment name.
deploy-prod:
concurrency:
# TEMP: run RUN_ID is stuck at GitHub and holds the original group. Revert when GitHub removes it.
group: ${{ fromJSON(needs.gp-init.outputs.config).prod.concurrencyGroup }}-tmp
cancel-in-progress: false
environment:
name: ${{ fromJSON(needs.gp-init.outputs.config).prod.concurrencyGroup }}
- Before starting deployments in the temporary group, pause new deployments and cancel superseded runs that still use the original group, including runs that haven't reached the deploy job yet. Confirm that no deploy other than the stuck job remains active or queued in the original group.
- Merge the change, resume deployments with the temporary group, and start a new deployment.
- Contact GitHub Support. Select Oslo kommune under Organization, then Actions > Stuck workflow. Include the run URL, the methods you tried and the error messages you got.
- When GitHub has removed the stuck run, pause new deployments again. Let active deployments in
-tmpfinish and cancel remaining runs that use that group, including runs that haven't reached the deploy job yet. Then remove the-tmpsuffix and resume deployments.
Waiting runs expire after 30 days
A run waiting for an environment review ends on its own after 30 days, which also frees the group.
Verify
Start a new deployment, or push to main. Check that it starts without waiting behind another run:
The latest run should show in_progress or completed, not waiting or pending.