Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are required inputs to GitHub Actions not enforced?

I'm writing a JavaScript action for GitHub Actions that has inputs, some of which are required. A simple example:

name: 'My action'
description: 'My description'
author: 'me'
inputs:
  thisOneIsOptional: 
    description: 'An optional input'
    required: false
  thisOneIsRequired: 
    description: 'A required input'
    required: true
runs:
  using: 'node12'
  main: '../lib/main.js'

What I find surprising is that I can use this action in a workflow without providing the required parameter and GitHub does not complain. It seems as though it is up to the action itself to validate that the required inputs were in fact provided. Is that right?

Is there anyway to get GitHub to validate this for me before my action code gets called?

like image 984
Stoatles Avatar asked Feb 27 '26 00:02

Stoatles


1 Answers

Currently GitHub does not check if required input has been passed. This is being tracked in this issue.

However, you can implement validation yourself using bash, e.g.

- run: |
    [[ "${{ inputs.docker_image_name }}" ]] || { echo "docker_image_name input is empty" ; exit 1; }
    [[ "${{ inputs.doppler_token }}" ]] || { echo "doppler_token input is empty" ; exit 1; }
  shell: bash
like image 155
Gajus Avatar answered Mar 04 '26 09:03

Gajus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!