Add environments and approvals

DevOps, Hands On20 minutesFreeWritten 14 November 2026By Cloud Hands On

In this task you'll make production deployments wait for an approval.

A GitHub environment (such as staging or production) holds its own secrets and protection rules: required reviewers, a wait timer, and which branches may deploy to it.

A job that names an environment pauses until the rules are met. With OIDC, the token's subject becomes environment:production, so Azure can trust production deployments separately from everything else.

Example. Ironbridge Payments deploys to staging automatically, but the production job waits for one of two named release managers to approve it in GitHub.

Before you start

You need: A public GitHub repository. Time: 20 minutes.

Where to look

  1. Repository
  2. Settings
  3. Environments
  4. New environment

Steps

  1. Open Settings, Environments, New environment and name it production.
  2. Add yourself under Required reviewers and limit Deployment branches to main.Required reviewers on private repositories need a paid plan.
  3. In the workflow's deploy job add environment: production.
  4. In Azure, add a federated credential with entity type Environment and name production.The branch credential won't match: the subject is now environment-based.
  5. Push to main and approve the waiting job from the run's page.

Commands

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    permissions:
      id-token: write
      contents: read
    steps:
      - uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

Watch out for

Cost
Free for public repositories.
Security
Put production secrets in the production environment, not at repository level, so other jobs can't read them.
Common mistakes
Leaving the branch-based federated credential in place, so a job without the environment can still deploy.

Clean up

Delete the environment from Settings, Environments when you've finished.

Words to know

Environment
A named deployment target in GitHub with its own secrets and rules.
Required reviewers
People who must approve before a job for that environment runs.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going