Define different workflow on different branches with workflow_dispatch #25412
-
Hi there folks, What I’m trying to achieve is to have 2 different protected branches with different workflows. The first one has workflow The thing is, I’m adding the workflow file only to the branch it applies to, so Also I want to trigger workflow Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
About your first question,
Sure, you can set up and run different workflows on different branches. About your second question,
Normally, when the workflow file is not on the on the default branch, the workflow will not be listed under All workflows on the Actions tab, unless the workflow has been triggered at least once. For the workflow_dispatch event, if you want to manually trigger the workflow_dispatch event on GitHub UI, the workflow file must be also on the default branch. If the workflow file only on other branches and not on the default branch, you need to use the “Create a workflow dispatch event” API to trigger the workflow_dispatch event on these branches. For more details, you can see “Manually running a workflow”. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot! I’ll give this a try and come back to accept your answer as soon as I have it working :slight_smile: |
Beta Was this translation helpful? Give feedback.
-
Hi! According to the docs for creating a workflow dispatch event the payload of the POST has a I’ve created a test repo with a PR that shows this behaviour miguelaferreira/test-gha-workflow-dispatch#1 The docs and the implementation don’t seem to align here. |
Beta Was this translation helpful? Give feedback.
@caiofaustino,
About your first question,
Sure, you can set up and run different workflows on different branches.
However, you also need to know that some events only trigger workflow runs if the workflow files are on the default branch, such as the events repository_dispatch, check_run, check_suite, etc. . These events are not available on other branches.
About your second question,