Is there any way to limit the branch against which workflow_dispatch events run? For example, I sometimes need to rerun terraform scripts, however, those scripts are modifying infrastructure so I only want to execute workflow_dispatch runs against master.
When you manually trigger the workflow with ‘workflow_dispatch’ event, it will ask you to provide the branch which you want to run on. Only if you defined dispatch event on the target branch, the workflow can be started.
Besides, you can add ‘ref: master’ to actions/checkout, always checkout master branch for the job.
Does it meet your requirement? If it’s not, could you please explain more about the example,
what’s the original, where’s the dispatch event defined, and what changed after terraform scripts?
Can you add a branch filter to workflow_dispatch events (similar to the mechanism for push and pull_request events)? The documentation does not indicate it’s possible.
This is an interesting option that I’ll need to dig into. Thank you for this idea! It would still be nice to have branch filters for workflow_dispatch though.
Thanks @zebraflesh for your quick reply!
Currently It’s not supported, thanks for your idea!
According to policy, it’s recommended to raise the feature_request in below link where is more appropriate, github product manager will take a review and help to answer.
Please kindly let me know if the ‘ref: master’ works for you.
Hi! I had the same issue and I solved it with a condition:
if: github.ref == 'refs/heads/master' steps: ...
in this way the user can see that the action is skipped when selecting a different branch.