Interview Prep/GitHub Actions/Secrets, Variables, Environments & Permissions

How do deployment branch policies interact with tags and `workflow_dispatch`?

AdvancedConceptSecrets, Variables, Environments & Permissions
Answer

The policy checks github.ref of the run against the allowed patterns. A workflow_dispatch from a feature branch targeting prod is rejected with "Branch 'feature/x' is not allowed to deploy to prod due to environment protection rules." Tag patterns must be added explicitly with type tag; allowing only main blocks a release workflow triggered by v1.4.0.

gh api -X POST repos/ORG/REPO/environments/prod/deployment-branch-policies \
  -f name='v*' -f type=tag
All GitHub Actions questions Roadmap: GitHub Actions

More on Secrets, Variables, Environments & Permissions