GitHub Actions rollback job missing production reviewers after schema change
0 reputation · 14 Mar 2020, 14:18 UTC
0 reputation · 14 Mar 2020, 14:18 UTC
The goal is to model a rollback workflow that runs after a failed production deployment containing a forward database migration, while preserving the same deployment protection rules that gated the original release. GitHub Actions environments can require reviewers and wait timers for deployment jobs, but it is unclear whether those rules automatically apply to a separate rollback job or workflow triggered by deployment_status.
Environment-scoped secrets and variables may also be unavailable if the rollback targets a different environment than production. Additionally, GitHub Actions provides no built-in schema-compatibility check to prevent rolling back to an earlier code version after shared tables have already been migrated.
Assuming standard GitHub Actions environments and deployment_status triggers, what configuration ensures the rollback job inherits production required reviewers? Can a rollback workflow access production environment secrets when it runs under a different environment name? Is there a supported way to block rollback until a schema compatibility review is completed?
36775 reputation · 14 Mar 2020, 16:00 UTC
No. A deployment_status trigger does not automatically carry production required reviewers into a separate rollback job. The rollback job must explicitly set environment: production so GitHub Actions applies the production deployment gate and pauses for required reviewers before the job starts. Environment secrets are scoped to the exact environment name, so a job using environment: rollback cannot read production environment secrets. GitHub Actions has no built-in schema-compatibility check; add a preflight job and gate rollback with needs.
on:
deployment_status:
types: [completed]
jobs:
schema-review:
if: ${{ github.event.deployment.environment == 'production' && github.event.deployment.status == 'failure' }}
runs-on: ubuntu-latest
environment: production
steps:
- run: ./scripts/verify-rollback-compatibility.sh
rollback:
needs: schema-review
if: ${{ success() }}
runs-on: ubuntu-latest
environment: production
steps:
- run: ./scripts/rollback-to-known-good-ref.sh --ref ${{ github.event.deployment.ref }}
gh api repos/OWNER/REPO/environments/production/protection_rules --jq '.[] | .type'
Assumes GitHub Actions environments and required reviewers are available for your repository and plan. For private repositories, required reviewers may depend on your GitHub plan; verify under Settings > Environments > production. This draft assumes the rollback targets the same repository and a known-good ref; automatic down-migrations after shared-table changes are unsafe and are not covered here. Requires current verification.
What environment value does the rollback job currently set? If it already uses production, investigate the deployment_status payload and job deployment mapping; if it uses a different name, switching to environment: production is the fix. This detail changes the recommendation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.