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.

 92 total views,  1 views today

Published inShort Tips

Be First to Comment

Leave a Reply