How to use workflow files only from a specific branch only?

I have a GitHub action that does something whenever a new issue is created.

Now the workflow yaml file is in dev branch.

And after pushing the yaml, file the action started.

I want actions to run from workflow files only in main branch.

Is there any settings option, to disable workfile file run from a specific branch?

Basically what I want is, workflow files which are in allowed branches, should run.

I am not talking about on : triggers.

I am talking about a general repo setting, that would enforce github to ignore any workflow files in branches other than allowed branches

1 Like

You can restrict what actions are allowed in workflows, but there is no repository setting to restrict on what branches workflows are allowed to run:

You could enable Require status checks to pass before merging and only let actions succeed if the branch is on an allow list, but that will have to be coded into the workflow itself.

1 Like