Skip to content

Short Tip on GitHub Actions:workflow_dispatch event input as execution condition

Reading Time: < 1 minute

“Github Actions” supplies a special event for workflows that can be triggered manually from the web interface. This event is workflow_dispatch. By default, it has only one input parameter: git branch that must be a context for the workflow execution. But the set of input parameters can be extended with custom ones.

The syntax is following:

on:
  workflow_dispatch:
    inputs:
      test-run:
        description: 'Test (y/n)?'
        required: true
        default: 'y'

And later on, the values of the inputs can be used as conditions for workflow steps:

jobs:
  build:
    steps:
      - name: Yes branch
        if: github.event.inputs.test-run == 'y'
        run: echo "Test = Y"

The sample workflow can be found on GitHub.

Loading

Published inShort Tips

Be First to Comment

Leave a Reply

We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept