GitHub Actions environment deployment branch policy pattern is invalid
An environment can restrict which branches/tags may deploy to it via deployment branch policies. These use name-pattern matching (not full regex); a pattern that does not match the deploying ref blocks the job from accessing the environment.
What this error means
A job targeting a protected environment is blocked because the ref does not satisfy the deployment branch policy.
Branch "feature/x" is not allowed to deploy to "production" due to the environment's deployment branch policy.
The branch does not match any configured deployment branch pattern.Common causes
Ref does not match the branch policy pattern
Only refs matching the configured name patterns may deploy to the environment.
Pattern written as full regex
Deployment branch policies use name patterns with wildcards, not arbitrary regex syntax.
How to fix it
Add a matching deployment branch pattern
- Open Settings > Environments > <env> > Deployment branches.
- Add a pattern (e.g. main or release/*) that matches the intended deploying refs.
Deploy from an allowed ref
- Run the deploy from a branch/tag the policy permits.
- Use wildcard patterns rather than full regex constructs.
# deployment branch pattern examples (name patterns, not regex)
main
release/*
v*How to prevent it
- Use name-pattern wildcards for deployment branch policies.
- Verify the deploying ref matches before relying on the environment.