Cannot deploy from "release published" on protected environment

Hello there,

we have our environments which are protected to deploy only on certain selected branches.
On the other hand, we would like to automatically deploy when a release is published.

I have a deployment workflow which listens to this event:

    types: [ published ]

Let’s say I have a production environment, which is configured to deploy only on branch main.
If I create a release with tag v1.0 on this branch for the environment production, the deploy workflow always results with this error: Branch "v1.0" is not allowed to deploy to production due to environment protection rules.

any idea please?


1 Like

I’ve run into this as well. It seems that tags will not match any of the branch rules. Is there any way we can get that added? That would really help.

1 Like

I guess that you already solved your problem, but as I had the same issue and I had to spend more time to fix it that I’d like to acknowledge, I am providing the solution here.

When publishing a release, the branch used in your GitHub Actions pipeline will be running with the tag name (“v1.0” in this case). You need to make sure that in your environment protection rules, you are allowing branches with your tag names to access the environment. For instance, you can allow branches with the “v*.*” name pattern.