@semantic-release/git and protected branches

133 Views Asked by At

When using the semantic-release plugin @semantic-release/git on protected branch (master is protected with maintainers allowed to merge and no one allowed to push and merge)

I have

remote: GitLab: You are not allowed to push code to protected branches on this project

I also tried with allowed to force push enabled but it changes nothing.

What's the solution ?

EDIT

If I unprotect the branch it is working.

The access token has all rights (I checked all boxes).

But I'm not sure that I can push something to a branch that has no one allowed to push and merge, even with any token.

I tried setting GITLAB_TOKEN with CI_JOB_TOKEN value. But it is not working. It tells me the token is invalid.

1

There are 1 best solutions below

3
KMZ On BEST ANSWER

When noone is allowed to push and merge, it means that only merge commits are allowed, and normal (direct) commits cannot be pushed.

Unfortunately, this is what the @sematic-release/git requires -- it is going to create a direct commit with an updated package.json and maybe other changes (changelog etc), and this direct commit will also be tagged with the version number the @sematic-release plugin generated.

Personally, I don't like this approach, and prefer to avoid extra commits that have no bearing on the code itself.

We didn't find a way to solve this without unprotecting the branches or at least allowing pushes. Eventually we migrated to custom versioning workflow which didn't need extra commits and used tags instead.