saitho / semantic-release-backmerge

:twisted_rightwards_arrows: semantic-release plugin to back-merge a release into a develop branch
https://saitho.github.io/semantic-release-backmerge/
56 stars 11 forks source link

(feat): option to only run if triggered from specific branch #26

Closed EinfachHans closed 2 years ago

EinfachHans commented 2 years ago

Let me describe 😃

I have to branches that are configured to run for semantic release: staging and *master**

both should back-merge to dev so i added

[
      '@saithodev/semantic-release-backmerge',
      {
        branchName: 'dev',
        clearWorkspace: true
      }
    ]

what worked great! 😊

But i also want another back-merge to a branch called trigger that should only run if semantic is currently running on master branch. Can you add such a feature or do you know a workaround?

EinfachHans commented 2 years ago

That shouldn't be that hard, see the commits here for how to do it: https://github.com/pustovitDmytro/semantic-release-heroku/issues/50

saitho commented 2 years ago

We could allow setting an array in branchName, which takes either string or objects. The object would take allow conditional backmerges by defining in from the source branch and to the target branch to backmerge to.

Not sure about the naming. I'd probably prefer to name it branches as well. If branches is given, branchName is ignored.

Backmerge to dev and dev2

branches: ['dev', 'dev2'],

Always backmerge to dev and to trigger if backmerge occurred from master

branches: ['dev', {from: 'master', to: 'trigger'}],
saitho commented 2 years ago

Thinking about it more thoroughly and keeping in mind that semantic-release now supports multiple stages (which it didn't when I made this plugin), I can definitely see the use case

EinfachHans commented 2 years ago

Yeah something like branches: ['dev', {from: 'master', to: 'trigger'}]' is exactly what would be awesome for me.

In my situation semantic release runs on eg staging & master branch. Also i have another branch that triggers a CI service to run, so i would like to rebase into that branch only when currently on master 😊