Skip to content

Instantly share code, notes, and snippets.

@embano1
Created May 26, 2021 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save embano1/f687f902d549c732bd2ea0ac6f2e26e4 to your computer and use it in GitHub Desktop.
Save embano1/f687f902d549c732bd2ea0ac6f2e26e4 to your computer and use it in GitHub Desktop.

Manually trigger Github Action Workflow from CLI

Motivation: the Github UI by default won't let you specify tags as input when triggering a workflow enabled with the on: workflow_dispatch event type.

Get Workflow ID

gh workflow list
Verify Docker Login      active  9450050

Trigger Workflow via API

Chose a valid tag which has the workflow definition (file) included.

⚠️ Note: It is not sufficient that the workflow just exists in the specified tag. The workflow version in that tag MUST have a on: workflow_dispatch trigger defined, otherwise "Workflow does not have 'workflow_dispatch' trigger" is returned.

echo '{"ref":"refs/tags/v0.3.1"}' | gh api repos/{owner}/{repo}/actions/workflows/9450050/dispatches --input -

On success the result will be 204, i.e. empty content. See API definition for details.

@embano1
Copy link
Author

embano1 commented May 26, 2021

Note that the short version to specify a tag also works, e.g. '{"ref":"v0.3.1"}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment