GitHub Actions Check Empty Dispatch Input

Viewed 1229

I have a workflow that is triggered by workflow_dispatch events with a few non-required string inputs and am trying to figure out how to determine if the value was provided or not.

on:
  workflow_dispatch:
    inputs:
      input1:
        description: first input
        required: false
        type: string
      input2:
        description: second input
        required: false
        type: string

The documentation says that unset inputs that are of type string will be equated to an empty string in the workflow but when I check that in an if clause condition for a job, it doesn't seem to be evaluating properly.

jobs:
  jobA:
    if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.input1 != '' }}
    # ...

Even when I dispatch the workflow with the input empty, both steps are ran.

What is the idiomatic way of checking if an input value was unset or not if this is not it?

1 Answers
Related