Sub topic 8
Approving or rejecting a waiting deployment
This chapter assumes you can read workflow YAML, know how needs orders jobs, and have already set up an environment with required reviewers. Here you follow what happens after a job reaches a protected environment: how it waits, who can approve it, and what each decision does.
What a waiting deployment looks like
When a job references an environment that has required reviewers, the runner does not start. GitHub puts the job in a waiting state and notifies the reviewers. The job does not use a runner while it waits, and it cannot read the environment's secrets yet.
A workflow run can wait for at most 30 days. If nobody decides in that time, the run is cancelled automatically.
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- run: ./deploy.sh
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}If production lists required reviewers, this job pauses before its first step.
Who can decide
Only people named as required reviewers can approve or reject. A reviewer can be a user or a team, and you can list up to six. Only one of them needs to approve for the job to continue. If you enabled Prevent self-review, the person who triggered the run cannot be that one approver.
The decision flow
Approving or rejecting in the UI
- Open the workflow run from the Actions tab, or follow the link in the notification.
- Select Review deployments in the waiting banner.
- Tick the environments you want to decide on.
- Optionally add a comment explaining your choice.
- Select Approve and deploy or Reject.
If a run waits on several environments, you can decide on them together or separately.
What each decision does
- Approve: the job leaves the waiting state, is assigned a runner, and the environment's secrets become available to it. Other protection rules, such as a wait timer or branch restriction, still apply.
- Reject: the job fails and the deployment is marked as rejected. Any job that lists it in
needsis skipped, so a rejected staging approval stops the whole pipeline.
A rejection is final for that run. To try again, push a new commit or re-run the workflow, which creates a fresh approval request.
Common mistakes
- No reviewer is notified. The reviewers list may be empty, or the reviewers lack access to the repository. Check the environment settings.
- You cannot see the approve button. You are probably not a listed reviewer, or self-review prevention is excluding you.
- The job never starts after approval. Another rule is still pending, such as a wait timer.
Exercise
A pipeline has build, deploy-staging, and deploy-production jobs chained with needs. A reviewer rejects the production deployment. What happens to the run, and how do you deploy that commit after fixing the problem?
Show answer
The deploy-production job fails and the run is marked as failed, while the earlier jobs keep their results. Rejection is final for that run, so you re-run the workflow or push a new commit, which creates a new approval request for the reviewers.