Skip to content
Latchkey

How to Set Default Input Values in a Custom Action

The default key on an input supplies a value when the caller omits it in with.

Add default: under an input. When a workflow does not pass that input, the runner uses the default, which stays a string like every other input.

Steps

  • Declare the input under inputs: in action.yml.
  • Add default: with the fallback value.
  • Callers may still override it with with:.

action.yml

action.yml
inputs:
  node-version:
    description: 'Node major version'
    default: '20'
  cache:
    description: 'Enable dependency cache'
    default: 'true'
runs:
  using: "composite"
  steps:
    - uses: actions/setup-node@v4
      with:
        node-version: ${{ inputs.node-version }}

Gotchas

  • Defaults are strings; a boolean-looking default is still 'true' or 'false'.
  • An input with a default cannot also be required: true meaningfully.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →