Workflows can be triggered by one of the following manual interactions:
- GitHub API
- GitHub CLI
- GitHub GUI (browser interface)
There are a couple of requirements in order for this to be enabled on a workflow:
- The workflow must be in the default branch
- The workflow must contain the
workflow_dispatch
event.
The following exercise will walk you through creating a manually triggered workflow, and then have you perform a manual execution through the GitHub GUI.
The only step in this exercise is to add the workflow to your default branch directly.
- Checkout the default branch of your repository
- Create a new file named
.github/workflows/manual.yaml
- Copy the contents below to the newly created file:
name: Manual Workflow
on:
workflow_dispatch:
inputs:
choice-example:
description: Choice Example
required: true
default: warning
type: choice
options:
- info
- warning
- debug
string-example:
description: String Example
required: true
default: input
type: string
jobs:
do-things:
name: Do Things Manually
runs-on: ubuntu-latest
steps:
- name: Do A Thing
run: echo "I've done a thing manually with '${{ inputs.choice-example }}' and '${{ inputs.string-example }}'!"
- Add, commit, and push your changes to the default branch.
- Go to your repository, and view the Actions tab to see the workflow you created (
Manual Workflow
)
The result will be a button (when viewing your workflow) you can use to execute the workflow.
- From the workflow view (see previous step):
- Click the "Run workflow" drop down button and then the green "Run Workflow" button:
The result will be an execution of the workflow above.
No further steps are needed as you committed directly to the default branch.