Inconsistent inputs context for workflow_dispatch and workflow_call

I’d like to have a workflow that can both be triggered manually and triggered by another workflow. Something like:

on:
  workflow_call:
    inputs:
      foo:
        required: true
        type: string
      bar:
        required: true
        type: string
  workflow_dispatch: 
    inputs:
      foo:
        required: true
        type: string
      bar:
        required: true
        type: string

However, I’m not sure I can do this. It seems like the way to inject the inputs context is different for each trigger.

For workflow_dispatch, the docs say to use ${{ github.event.inputs.<variable_name> }}.

For workflow_call, the docs say to use ${{ inputs.<variable_name> }}.

Is there a way to make this work in one yaml file?

${{ github.event.inputs.<variable_name> || inputs.<variable_name> }}

1 Like