GitHub Actions allows to define workflow_dispatch
workflow trigger:
on:
workflow_dispatch: # manual trigger
This event allows to manually trigger the workflow via UI, rest API call or CLI. But according to the docs:
This event will only trigger a workflow run if the workflow file exists on the default branch
which is quite inconvenient during development of workflows, or when a workflow must be triggered on a side/release/hotfix branch, or when actions in the workflow rely on specific triggers.
Solution
Contrary to what documentation says, it’s actually possible to send workflow_dispatch
event to a workflow,
which does not exist on the default branch.
Prerequisite: the workflow must run at least once. For example, temporary add a pull_request
trigger
to the workflow, create a PR and let the workflow to start. After that pull_request
trigger can be removed.
Use CLI to send the event to the side branch:
export GITHUB_TOKEN=YOUR_GITHUB_TOKEN
gh workflow run manual_workflow.yaml --repo my_org/my_repo --ref side_branch
and go to “Actions” tab of your repo to watch the workflow run.