workflow-dispatch
workflow-dispatch copied to clipboard
Cannot dispatch with commit SHA
The reference can be a branch, tag, or a commit SHA.
But when using a SHA, the action fails with: No ref found for: <commit sha>
Indeed, the Github API doc says:
ref: Required. The git reference for the workflow. The reference can be a branch or tag name.
Which would explain why it fails when passing a commit sha
Can we fix the Readme to remove the use case for sha?
I don't think this is the case, I'm using the sha on multiple workflow triggers and it works just fine. I'm actually running into the same issue with ref so there must be another underlying cause.
Dispatch
name: PR Verification
on:
pull_request:
jobs:
# https://github.com/benc-uk/workflow-dispatch
verification:
name: Trigger - Lint, Test & Build
runs-on: ubuntu-latest
steps:
- name: Trigger Workflow
uses: benc-uk/workflow-dispatch@v1
with:
inputs: '{ "ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
token: ${{ secrets.REPO_ACCESS_TOKEN }}
workflow: Lint, Test & Build
Triggered Workflow
name: Lint, Test & Build
on:
workflow_dispatch:
inputs:
ref:
description: 'GitHub REF to be used for checkout'
required: false
sha:
description: 'GitHub SHA to be used for checkout'
required: true
Error using sha
Run benc-uk/workflow-dispatch@v1
with:
inputs: {"sha": "86b842d5629262a44a7a1614fe361f1ffdee4597"}
token: ***
workflow: Lint, Test & Build
Workflow id is: 8600649
Error: No ref found for: refs/pull/547/merge
Error using ref
Run benc-uk/workflow-dispatch@v1
with:
inputs: {"ref": "master"}
token: ***
workflow: Lint, Test & Build
Workflow id is: 8600649
Error: No ref found for: refs/pull/547/merge
Error using github.event.pull_request.head.ref
Run benc-uk/workflow-dispatch@v1
with:
inputs: {"ref": "master"}
token: ***
workflow: Lint, Test & Build
Workflow id is: 8600649
Error: No ref found for: refs/pull/547/merge
Following up here, any plan to address this?
@CWSites could it be because you’re on a branch? Workflow dispatch only works when the triggered workflow is on master
Hey @saliceti I am on a branch, trying this as part of my PR verification to use the same test config as my Release workflow. My understanding from GitHub is that workflow dispatch shouldn't be limited to master?
Sorry I think I confused it with repository_dispatch and assumed it's the same issue
Still an issue :(
@saliceti @CWSites try ${{ github.head_ref }}
I used the github-script action though:
- name: Trigger Workflow
uses: actions/github-script@v6
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'new-workflow.yml',
ref: '${{ github.head_ref }}',
})
So the equivalent with this action
- name: Invoke workflow with inputs
uses: benc-uk/workflow-dispatch@v1
with:
workflow: new-workflow
token: ${{ github.token }}
inputs: '{ "exit-code": "1" }'
ref: ${{ github.head_ref }}
Thanks @joshjohanning - I'm closing this as you seem to have solved the problem
How is the head_ref solving the issue faced when trying to use sha?
This looks like an API limitation: github/docs#590