How to Gate a Release on Manual Approval in GitHub Actions
Pointing the publish job at a protected environment with required reviewers pauses the run until a reviewer approves the release.
Create an Environment (for example release) with required reviewers, then set environment: on the publishing job. The run waits in a pending state until someone approves.
Steps
- Open Settings to Environments and add required reviewers to a
releaseenvironment. - Split build (unguarded) from publish (guarded).
- Set
environment: releaseon the publish job andneeds: build.
Workflow
.github/workflows/release.yml
on:
push:
tags: ['v*.*.*']
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: make build
publish:
needs: build
runs-on: ubuntu-latest
environment: release
steps:
- run: ./publish.shGotchas
- The approval gate lives on the environment, not the workflow file.
- A reviewer cannot approve their own run when the environment forbids self-review.
Related guides
How to Promote a Pre-Release to Stable in GitHub ActionsFlip a GitHub pre-release to a stable release in GitHub Actions with gh release edit --prerelease=false and -…
How to Roll Back a Bad Release in GitHub ActionsRoll back a bad release in GitHub Actions by deleting the release and tag with the gh CLI, or by re-pointing…