Skip to content
Latchkey

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.

github-actions
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

  1. Open Settings > Environments > <env> > Deployment branches.
  2. Add a pattern (e.g. main or release/*) that matches the intended deploying refs.

Deploy from an allowed ref

  1. Run the deploy from a branch/tag the policy permits.
  2. Use wildcard patterns rather than full regex constructs.
environment settings
# 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.

Frequently asked questions

What causes "deployment branch policy invalid"?
Only refs matching the configured name patterns may deploy to the environment.
How do I fix deployment branch policy invalid?
Add a matching deployment branch pattern

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card