By default, GitHub Actions does not allow you to run a workflow manually. In order to enable manual workflow runs, I had to add workflow_dispatch to the YAML file under .github/workflows/.

For example, the beginning of my GitHub Actions YAML file looked like this:

1
2
3
4
5
name: Deploy
on:
  push:
    branches:
      - master

This configuration allows for workflows to run on commit pushes to the master branch, but there is no option to run this workflow manually on GitHub:

GitHub Actions doesn't show a manual way of running the workflow.

To enable manual runs of workflows, I added the workflow_dispatch key. There was no need to add anything else under it:

1
2
3
4
5
6
name: Deploy
on:
  push:
    branches:
      - master
  workflow_dispatch:

After pushing changes, I was able to see a “Run workflow” button that allows me to run the workflow manually.

GitHub Actions now shows a manual way of running the workflow.

You can also run workflows using the GitHub CLI once workflow_dispatch is in your workflow YAML file. Assuming your workflow YAML is named main.yml, you can run:

gh workflow run main.yml

And you’ll get output similar to the following:

✓ Created workflow_dispatch event for main.yml at master
https://github.com/nelsonfigueroa/nelson.cloud/actions/runs/22656361802

To see the created workflow run, try: gh run view 22656361802

Note that there are a lot more configuration options available when adding the workflow_dispatch key. However, I just wanted to enable manual runs and nothing more. Refer to the documentation for more information.

References