GH actions inputs defaults not working when ENV present

Hi!

I got some problem with a custom action that does not set the default value when an ENV is present, but empty.

I created a custom action that takes an input:

name: "build"
description: build with parameter
inputs:
  IMAGE_TAG:
    description: "the image tag"
    required: true
    default: latest

The action is called within the workflow file:

- name: build
      uses: ./actions/action-name
      with:
        IMAGE_TAG: "${{ env.RELEASE_VERSION }}"

A custom script that is run in a previous workflow step sets the ENV RELEASE_VERSION by adding this to $GITHUB_ENV.

echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV

So the run environment has something like when the ENV is empty:

# printenv
RELEASE_VERSION=

To the problem:
I can’t get the default value set from the custom action.
I would expect that the action would set IMAGE_TAG to the default value if the input parameter is empty.
Apparently it does not set the default value when the parameter is present.
Something like unset RELEASE_VERSION does not work since it is still present in the GITHUB_ENV file.

What am I missing? Is this expected behaviour?

What happens if you remove the double quotes where you use the action?

IMAGE_TAG: ${{ env.RELEASE_VERSION }}

It’s just a wild guess, but the quote marks might cause the value to be an empty string, whereas the above might evaluate to null in YAML and then perhaps use the default value.

Or it’s the presence of the environment variable as you say, in which case you should not set RELEASE_VERSION at all. Is there any reasons you set it if it’s empty?