workflow-dispatch
workflow-dispatch copied to clipboard
Issues when triggering a workflow in another repository
I'm having some issues when triggering a workflow in another repository.
Let's say that I'm developing something in Org/A repository and I want to trigger a workflow in Org/B repository from some Org/A workflow's job:
- name: "Trigger B Workflow"
uses: benc-uk/workflow-dispatch@v1
with:
repo: "Org/B"
workflow: "Workflow B"
token: ${{secrets.XXX}}
inputs: '{ "someInput": "someValue" }'
The problem is that if this workflow is executed in branch "XYZ" in Org/A I get the following error:
No ref found for: refs/heads/XYZ
I'm really not sure anymore whether I wrote it wrong or whether this is a bug in benc-uk/workflow-dispatch?
I am experiencing the same issue:
Run benc-uk/workflow-dispatch@v1
with:
workflow: Java CI
repo: yooksi/java-workflows
token: ***
Workflow id is: 5761042
Error: No ref found for: refs/heads/master
I experienced this same error when triggering from the master branch of one repo and targeting a remote repo that doesn't have a master branch (the "target" repo uses main instead).
I was able to resolve the issue by hard-coding the ref as refs/heads/main, which feels wrong but appears to be a workaround:
- name: Pin new image version in the k8s deployment repo
uses: benc-uk/workflow-dispatch@v1
with:
ref: refs/heads/main # <-- this action is triggered in a repo with a 'master' branch, but targets a repo that uses 'main'
workflow: Update pinned image tag
repo: my-org/my-remote-repo
token: ${{ secrets.WORKFLOW_TRIGGER_TOKEN }}
inputs: '{ "tag": "${{ steps.vars.outputs.sha_short }}"}'
My action is simply triggering the GitHub API, and for the default ref I use the standard variable github.context.ref
When triggering remotely and the two repos have different default branches, you probably will need to set the ref yourself