Can I trigger action on push to default branch

For now I have to do

      branches:
        - master

Is it possible to have kind of default, like

      branches: default

That would be great, as master no longer is that obvious. Any ideas?

1 Like

I don’t have a solution; but, I do have a perspective. I’ve gotten bogged down trying to use GitHub Actions as if it were a normal programming language, where I can do most anything I want.

It seems like you want to make a generic workflow file that could handle any repo with a default branch named anything. Or one where the default branch to be changed … maybe often.

But isn’t it more likely that your repo will have one default branch that remains unchanged forever or at least almost forever. In that case, you would set the branch name once and probably never change it again.

@bsa-coder yeah, problem is with this new world, where one country forces entire world to change their understanding of words and forces “main” over “master”.

So now I have a bunch of repos with “master” and all the new once come with “main”. And even though I do not understand why “master” is evil, I want to respect others and if I get repo with “main” I want to keep it and not change to “master”.

Now, I have workflows that are the same in all repositories, like -> https://github.com/asyncapi/.github/blob/615fa9d44aafc55e0698d45d0c070eeb4d2929ab/.github/workflows/automerge.yml. When I want to make changes to it, I do not make commits/prs/merge to 37 other repos, but just make a change to this single file and replicate the change with my custom action https://github.com/derberg/global-workflows-support.

The problem I have now, is that I cannot have global workflows that react on commit to default branch.

Does it make sense?

It never occurred to me that ‘master’ was evil … oh well.

If the problem is just that ‘main’ has replaced ‘master’ on new repos and assuming that ‘master’ will be gone for the future, then change your YML to

branches: [main, master]

Then you’ll get the same results. Old ‘master’ repos will get triggered and use your new-improved YML and new ‘main’ repos will also.

@bsa-coder yeah this is the only workaround that eventually I will apply. Thing is that it is just a workaround. I always take into account that I run away from project at some point of time and then such workarounds are unknown until they make something fail :frowning: thus why I created this thread hoping core maintainers might notice and pull to the roadmap :smiley:

I agree … after all Git allows you to set the default so why wouldn’t they allow you to use it in Actions. It seems simple enough.

1 Like