How to Enable Manual Runs of GitHub Actions Workflows

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:

name: Deploy
on:
  push:
    branches: 
      - master

This configuration allows for workflows to run on commit pushes, 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 and specified the master branch:

name: Deploy
on:
  push:
    branches: 
      - master
  workflow_dispatch:
    branches:
      - master

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

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

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