Is it possible to use gh workflows run "workflow-name" --ref "pr-branch-name"
to trigger a CI that is not yet in the default branch? Because today I can only trigger workflows that are already in the default branch.
HTTP 404: Not Found (https://api.github.com/repos/Kaua3045/monorepo-testes/actions/workflows/order-command-ms-ci.yml) Even though the action is in the --ref branch, it says it couldn't find it, I had the same problem using curl
GitHub Actions does not allow us to run workflows that have not been pushed to the default branch. It is impossible to even discover workflows that only exist on a branch. Both GitHub API and GitHub CLI do not return them. They will also not appear under the Actions
UI.
Attempts to run a workflow that only exists on a branch will return 404 as GitHub can not find this workflow on the default branch.
Once a workflow has been pushed to the default branch, it can be manually run on the default branch or on any other branch started off the default branch after the push (provided the workflow defines a workflow_dispatch
trigger)
If a workflow is deleted on a branch, it can no longer be run on that branch. Surprisingly, I received this error trying to run a deleted workflow using GitHub CLI:
gh workflow run branch-workflow --ref branch-workflow
Could not create workflow dispatch event: HTTP 422: Workflow does not have 'workflow_dispatch' trigger (https://api.github.com/repos/owner/repo/actions/workflows/107960669/dispatches)
The reason for this is most likely implementation efficiency/cost and user experience - a repo may have hundreds of branches, many of them potentially abandoned. A workflow most likely only gets a DB record once it is merged into the default branch.
It is too bad there is no flag to persist a workflow in a DB record even with some limit of branch-only workflows per repo. Again, this is likely due to extra implementation complexity.
I usually create a minimal workflow and push it to the default branch. Then I create a feature branch and start implementing the workflow.