Abstract

Manual Github Workflow dispatching can be a convenient way to trigger repeatable tasks that are not tied to our usual Continuous Delivery Pipeline. For example, we might need to quickly trigger a rollback of our system, when we get an on-call incident. We might use our computer and trigger the workflow in the Github web app. However, quickly dispatching a workflow with iOS Shortcuts may be more handy. This article describes how to set it up.

To dispatch a Github Actions Workflow, iPhone Shortcuts app requires a couple of parameters:

  • owner,
  • workflow id,
  • repository,
  • branch/ref,
  • inputs, and
  • account.

They can be easily obtained with the Github CLI tool1. The following snippet is taken from the Github API docs2.

1gh api \
2  -H "Accept: application/vnd.github+json" \
3  /repos/<owner>/<repo>/actions/workflows

The inputs have to be in JSON format, as in the following request snippet3.

1curl \
2  -X POST \
3  -H "Accept: application/vnd.github+json" \
4  -H "Authorization: Bearer <YOUR-TOKEN>"\
5  -H "X-GitHub-Api-Version: 2022-11-28" \
6  <github api url>/repos/<owner>/<repo>/actions/workflows/<workflow id>/dispatches \
7  -d '{"ref":"topic-branch","inputs":{"name":"Example name","home":"San Francisco, CA"}}'

Example

 1shortcut:
 2  name: Dispatch Workflow
 3  owner: github-username
 4  workflowId: 00000000
 5  repository: your-repo
 6  branchOrRef: master
 7  inputs: |
 8    {
 9      "name": "Example name",
10      "home": "San Francisco, CA"
11    }    
12  account: github-username

Footnotes

  1. Github CLI tool (gh) (accessed Feb. 05, 2023) 

  2. List repository workflows — Github REST API docs (accessed Feb. 05, 2023) 

  3. Create a workflow dispatch event — Github REST API docs (accessed Feb. 05, 2023)