Automation

GitHub Actions: validate environment approval before an Azure deployment

A production runbook for proving GitHub Actions approval protects an Azure deployment, including alternate paths, negative tests and rollback.

05 Dec 2026 github-actionsazuredevopssecuritydeploymentrunbookrollbackproduction

A team adds an approval gate to its GitHub Actions production environment. A different workflow can still obtain an Azure identity and deploy without that gate. An approval screen alone does not prove that every write path is protected.

This runbook follows an API deployed to Azure by GitHub Actions using OIDC federation. The names are illustrative. The aim is to show, against a canary target, that an unapproved run cannot change the target, then prove that an approved run deploys the intended artifact.

Map the write paths first

Record the repository, workflow and commit, triggering event, branch or tag, artifact and digest, GitHub environment, Azure identity and role scope. Inventory reusable workflows, other repositories, identities, secrets and manual procedures that can change the same target.

In the YAML, identify each job with id-token: write, a secret or another deployment capability. Environment rules apply only to a job that references that environment; approval on a neighboring job does not automatically protect the others. Review who can change workflows, environment settings and branch rules as well. Someone who can alter those controls may be able to create another path.

Bind approval to the Azure identity

Explicitly create and configure the production environment before using it. Review required reviewers, optional self-review prevention, allowed branches and tags, and whether administrators can bypass protection. Feature availability depends on the plan and repository visibility. Configuring multiple reviewers does not require multiple approvals: the documented behavior requires only one.

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    permissions:
      contents: read
      id-token: write
    steps:
      - name: Verify and deploy the approved artifact
        run: ./deploy-approved-artifact.sh

This excerpt shows where the gate belongs, not a runnable deployment: the script, authentication, artifact retrieval and verification still need to be implemented. The job is sent to a runner only after its configured protection rules pass; it can then access that environment’s secrets. A repository secret or a different identity does not inherit this protection.

For OIDC, inspect the Azure identity’s trust contract: issuer, audience and accepted subject must match the intended context. If the subject uses the environment, verify the exact match with the token actually issued, without logging the token. Look for other federated credentials, secrets and roles that can reach the same resource. A GitHub environment is not a sufficient boundary while another identity retains equivalent access.

Prove denial against a canary

Use a test resource and identity with no effect on production. Retain the run ID, commit, artifact digest, approval decision and relevant Azure logs, without tokens or secrets.

TestExpected result
Job references production, without approvalJob waits; no write reaches the target.
Rejection or disallowed branchDeployment is denied; target remains unchanged.
Self-review prevented, when available and configuredThe initiator cannot approve their own run.
Job without the environment or another workflowOIDC exchange or Azure authorization fails for this target.
Authorized reviewer and verified artifactJob starts and changes only the intended canary target.

Adapt the negative tests to the rules actually enabled. An interface failure is not enough: inspect target state and available authentication and activity records too. If an alternate path succeeds, the gate has not been proven; do not test that path against production.

Release, observe and recover

Before cutover, retain the previous environment, workflow and OIDC trust configuration, the stable artifact and an approved recovery procedure. Have trust and permission changes reviewed, then restrict the first release to a canary. The reviewer needs the commit and digest being promoted; verify the artifact again when it is consumed. Approval alone proves neither its contents nor its safety.

After deployment, compare the identity used, resources changed and version actually served with the approved evidence. Run a representative transaction and watch errors for a workload-appropriate window.

Decision: expand only after both the expected denials and approved path are demonstrated. If they diverge, pause deployments and remove the offending write path. Restore the stable application version through an approved procedure, then restore the previous configuration only if it remains safe; do not reopen broad access merely to unblock the pipeline. An action already performed may require separate compensation or data recovery.

References