Workflow Dispatch from a tag in actions tab

Hi there,

According to rest api documentation, workflow_dispatch takes in a ref

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

However, the UI only provides branch as the option. Is there anyway we can add tags?



@wei ,

When trying to manually trigger a workflow on the workflow_dispatch event, there are some differences between triggering from GitHub and triggering using the REST API.

  1. To trigger the workflow_dispatch event on GitHub, your workflow must be in the default branch, otherwise you can’t see the “Run workflow” button on GitHub. If you want other branches can be the optional ref of the workflow, the workflow also must be in these branches. Currently, the optional ref only can be branch. Tag and commit SHA are not supported here.

  2. To trigger the workflow_dispatch event using the REST API, your workflow does not have to be in the default branch as long as the workflow is in the optional ref (branch, tag, or a commit SHA).

If you really need the feature that can select branch, tag or commit SHA as ref when triggering the workflow_dispatch event on GitHub, I recommend that you can directly report a feature request here.
That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.


I am lost when trying to use the workflow_dispatch API, the response is either 422 nil is not an object, or not found

Also see Workflow dispatch - can't set ref to commit SHA

A commit hash isn’t supported, but tags are accepted by the REST API.

curl \
  -d '{"ref":"{tag}"}' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/vnd.github.v3+json' \
  -H 'Authorization: token {access-token}' \

The expected reply in case of a successful dispatch is HTTP/1.1 204 No Content without payload.

Depending on the shell you use, it will require a slightly different syntax for the curl command. For example, in PowerShell Core, there is a long-standing issue with quoting. The data part needs special escaping:

  • single quoted string, " escaped as \":
    -d '{\"ref\": \"...\"}'
    – or –
  • double quoted string, " escaped as \`":
    -d "{\`"ref\`": \`"...\`"}"

(Note that this was tested with actual curl, not the aliased command for Invoke-WebRequest)

1 Like

@brightran @AndreaGriffiths11 I report a feature request, but what is needed for this functionality to get into the Github roadmap?

We use deploy by tag, because deploy from brunch is not reliable. A tag is harder to change than a brunch. The lack of trigger the workflow_dispatch event on UI by tag stops us from migrating to GA.

It seems to me that this is not a difficult task to add this functionality at the frontend level. And do not look for workarounds.



@ahdbilal ^^^
What is needed to trigger the workflow_dispatch event on UI by tag to get into the Github roadmap?


Do you have a link to the feature request? Can it be upvoted? We need this as well.


^^^ @alexcnichols @Sid-ah

What in the world OMG ROFLOL!!!

Please, pretty please, can you elaborate on how deploying from branches isn’t reliable, but deploying from tags is!?

I’m really looking to learn this!

1 Like

The difference is:

deploy master - deploys different code over time
deploy v1.2.3 - deploys always commit abcd1234 (assuming you have not changed tags behind the scenes)

So from that point of view deploying tags is more reliable, since you can rely on the outcome of the deployment


This feature is now actually available.
Note: the Tags tab is only shown when there are actually tabs in the repo.

(I wanted to add a screenshot but apparently we’re not allowed to).