Workflow dispatch - can't set ref to commit SHA


I’m using the GitHub workflow dispatch event to manually run an end-to-end test workflow for an open source project. However, it seems like I’m unable to pass a commit in the ref input. This workflow step is triggering it:

 - name: Trigger end-to-end tests workflow
        # Note: we only run e2e tests automatically if this PR is not from a fork, as forks won't have access to secrets
        if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }}
        uses: benc-uk/workflow-dispatch@v1
          workflow: End-to-end Tests
          token: ${{ secrets.BOT_GITHUB_TOKEN }}
          ref: ${{ github.event.pull_request.head.sha || github.sha }}

This is using the plugin benc-uk/workflow-dispatch that calls the workflow dispatch REST endpoint:

Errored workflow:

The error is this:

Run benc-uk/workflow-dispatch@v1
    workflow: End-to-end Tests
    token: ***
    ref: f04d309a1b048e934b99b2e1d4d6ff77e5458203
Workflow id is: 2972449
Error: No ref found for: f04d309a1b048e934b99b2e1d4d6ff77e5458203

From REST documentation here it says ref can point to a commit:

Required . The reference of the workflow run. The reference can be a branch, tag, or a commit SHA.

So it doesn’t seem to be issue with this action.

However, this commit already exists here when run for the workflow, so not sure why it’s not picking up?

If passing github.ref it works but then it will run on the HEAD commit of master, but we want to run on specific commit and have workflow also show that commit. I guess a workaround is to pass sha as an input and then ensure to checkout that specific commit, but it may not be ideal as it could be confusing (the workflow itself is pointing to the HEAD).

Wondering if anyone else is facing a similar issue? Thanks in advance!

I can reproduce the problem - the endpoint accepts branch names and tag names, but not SHA-1 commit hashes for the ref attribute. I also tried sha, hash, object and commit but they are not permitted:

"message": "Invalid request.\n\n\"commit\" is not a permitted key.\n\"ref\" wasn't supplied."

If I look at the List matching references API, then I don’t find anything about commit hashes as :ref. I tried a couple of things like ${sha}, commits/${sha} and objects/${sha::2}/${sha:2} but to no avail. If it’s not available there, then the dispatch API probably doesn’t accept commit hashes either and the documentation is just wrong.

This is also supported by the UI:


You can only choose a branch. Curiously, you cannot select a tag, even though this is supported in the API.

1 Like

I created a docs issue:

The REST API source files seem to be in a private repository


@dphang, @Simran-B,

This is a legacy issue that had been reported earlier.

Looks like, the issue is still existing and not fixed.

Thanks for letting us know, I was not able to find that via search. We can follow that thread in that case. It will be good to fix this as it will allow running workflows in same context as the caller - e.g in this case running end-to-end tests workflow on same commit SHA as the triggering workflow (build workflow in my case).