Lorixen.
EN

Require approval before production deploys in GitHub Actions

Short answer: In GitHub Actions, create a production environment in the repository settings, add required reviewers, restrict which branches can deploy to it, and move production secrets into the environment. Any job that names that environment then pauses until an approved person clicks "Approve", and only then can it read the production secrets. Check your plan first: GitHub's documentation says required reviewers on private repositories aren't available on the Free, Pro or Team plans, though other controls are.

Why add an approval step

Automatic deploys on every merge are great until a half-finished feature, a broken migration or a Friday-evening change goes live while nobody is watching. An approval step gives you:

  • a deliberate moment where someone confirms the timing
  • a record of who approved each production deploy
  • protection for production secrets, which ordinary jobs can no longer read

It doesn't slow down staging or preview deploys, which can stay fully automatic.

How environments work

GitHub's documentation describes environments as targets such as staging or production with their own protection rules, secrets and variables. A job that references an environment must satisfy the environment's rules before it runs or accesses its secrets.

In the workflow, it's one line on the deploy job:

jobs:
  deploy-production:
    runs-on: ubuntu-latest
    environment: production
    steps:
      - ...

Setting up the production environment

In the repository's settings, under Environments, create production and configure:

Required reviewers. GitHub's docs say you can enter up to six people or teams, and that only one of them needs to approve for the job to proceed. Pick people who understand the release, and include more than one so a holiday doesn't block deploys.

Prevent self-review. This option stops people approving workflow runs they triggered, even if they're a listed reviewer, so the person who started the deploy can't wave their own change through. GitHub's reference notes this ensures deployments are always reviewed by more than one person. Reviewers need at least read access to the repository.

Wait timer. An optional delay before the job proceeds, useful as a cooling-off period or to let a staging check run first. GitHub's reference gives the range as 1 to 43,200 minutes (30 days) and says the waiting time isn't billed.

Admin bypass. By default, administrators can bypass protection rules. The docs describe deselecting "Allow administrators to bypass configured protection rules" if you want the rules to apply to everyone.

Deployment branches and tags. Limit which branches or tags can deploy to production, such as main or tags matching v*. This stops someone deploying an experimental branch by running the workflow manually. One trap from GitHub's reference: the "Protected branches only" option allows every branch if no branch protection rules exist, so either protect main or name the branches explicitly.

Environment secrets and variables. Move production credentials here. GitHub's docs explain they're only available to jobs using that environment, and only after its rules, such as required reviewers, have passed.

Check your plan

GitHub's documentation sets out availability. Environments, environment secrets and protection rules are available for public repositories on all current plans. For private repositories, environments, environment secrets and deployment branches need GitHub Pro, Team or Enterprise. Required reviewers and wait timers on private repositories aren't available on Free, Pro or Team plans. If you can't use required reviewers, you can still use branch restrictions, environment secrets and a manually triggered deploy workflow limited to specific people.

A sensible workflow shape

  1. On every push to main: run tests, build once and deploy to staging automatically.
  2. A deploy-production job that depends on the staging job, references the production environment and deploys the same build.
  3. Reviewers get notified, check staging, and approve.

Deploying the same build artefact you tested on staging, rather than rebuilding, avoids surprises.

Watch out for workflow edits

Anyone who can change the workflow file could, in principle, remove the environment: line and deploy without approval, unless production secrets live only in the environment. That's the main reason to move them there: a job that skips the environment simply can't reach production. Protect the main branch with required pull request reviews too, so workflow changes get the same scrutiny as code.

Reviewers' checklist

Give approvers a short, consistent list, in the pull request template or the team's notes:

  • Has the change been checked on staging?
  • Are database migrations included, and are they safe to run with traffic?
  • Is this a good time, such as not during a sale or a client's busy period?
  • Is someone available to watch for errors after the deploy?

Automated checks as gates

GitHub's reference also describes custom deployment protection rules, currently in public preview, which let third-party services such as monitoring tools approve or block deployments automatically, for example holding a deploy while error rates on staging are high. For most small teams a human reviewer is enough to start with, but it's worth knowing the option exists as your release process matures.

Emergencies

Decide in advance how urgent fixes go out. A fast approval from any listed reviewer is usually enough. Avoid creating a back door, like a second workflow without protection, which quietly undoes the whole setup.

A worked example

An illustrative Dublin web agency deployed client e-commerce sites straight to production on every merge, and once released an unfinished checkout change during a client's sale. They added a production environment per repository with two senior developers as required reviewers, enabled prevent self-review, restricted deploys to main, and moved payment and database credentials into environment secrets. Staging still deploys automatically, and production deploys now wait for a second person's approval.

FAQ

Can approvals happen from a phone?

Reviewers get a notification and can approve from GitHub's website or mobile app.

Do reviewers need write access?

GitHub's reference says reviewers need at least read access to the repository.

What happens if nobody approves?

The job waits, and eventually times out. Re-run it when ready.

Can I require approval for staging too?

Yes, but most teams keep staging automatic and fast.

If you'd like a safer path from merge to production, tell us how your team deploys today and we'll help you set up environments and approvals.

Sources

WhatsAppBook a call