Deployment Environments and Gates
Separate verification from deployment
Continuous integration validates a revision. Deployment changes an environment. A deployment gate is a policy decision before the change: require successful tests, a verified artifact, an allowed ref, and approval where configured. Staging rehearses changes before production. Promote the same verified artifact rather than rebuilding from an unrelated revision.
Reference environments
This inactive rehearsal only echoes messages. environment references a GitHub environment; it does not itself configure approval. Configure protection rules separately in repository settings, restrict deployment refs, and verify plan and repository visibility support. Never assume a newly named environment is protected. needs blocks production after a staging failure; both jobs have a small timeout.
name: Deployment rehearsalon: [workflow_dispatch]permissions: {}jobs: staging: runs-on: ubuntu-latest environment: staging-demo timeout-minutes: 5 steps: - run: echo 'Simulated staging verification' production: needs: staging runs-on: ubuntu-latest environment: production-demo timeout-minutes: 5 steps: - run: echo 'Simulated production verification'Gate and secret boundaries
Where required reviewers are configured, the job waits for approval before accessing environment secrets. Prevent self-review where supported and separate approver from author. A gate must bind the decision to the exact artifact digest and target; approval is not proof of artifact integrity. A production health check verifies the result after deployment.
Plan rollback and practice
Before deployment record the current known-good artifact, configuration compatibility, responsible operator and verification procedure. If verification fails, stop promotion and evaluate rollback; irreversible data migrations may require forward recovery instead. In the mock lab, absent approval waits, rejection stops, failed staging or digest mismatch denies. No deployment is executed.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Deployment Environments and Gates — knowledge check
Reason about reliable delivery and trust boundaries.
Does naming an environment automatically establish approval rules?
Which artifact should be promoted?
What should happen if staging fails?
What does absent required approval mean?
What is needed before rollback?