Support set but empty env variables
Act version
act version: 0.2.75
Feature description
There are scenarios where we want to support sending empty vars and/or secrets into a workflow. But attempting to do this via any of the below scenarios doesn't work:
export MY_VAR=''
act --var MY_VAR
# act asks for input
export MY_SECRET=''
act --secret MY_SECRET
# act asks for input
act --var MY_VAR=''
# act asks for input
act --secret MY_SECRET=''
# act asks for input
We should support the ability to pass in a var or secret via the command line or a set-but-empty env var
You can use var files.
--var-file= --secret-file=
with .env format VAR=Value or just VAR=
Tho, I don't see the use case for empty vars.
You can check if env var exists (even with empty value) if [ -z "${VAR+x}" ]; then 'not set' else fi
But there is no such format for ${{ vars.VAR+x }} to test if its set.
Still the using a file will allow you to set multiple vars/secrets without the tool prompting for empty values
Thanks for the feedback but I didn't ask if there was a way to pass in an empty variable, I said those specifically listed scenarios don't work.
Testing for a variable, set yet empty, etc, is not relevant here -- the issue isn't within the workflow, it is to avoid act querying the user for a variable that we know is not going to be relevant (or we know is going to be empty)-- our use of act is highly scripted for testing purposes and asking for a variable prevents us automating this.
One specific example is the use of aws-actions/configure-aws-credentials -- a user using the AWS CLI to authenticate may not need to use role-to-assume but an IAM user used as a service account often times will. To support using the GHA via act and also running as a service account in GitHub we have to set a variable for role-to-assume in with: but for act it will always be empty. We have several other scenarios similar to this but are more unique/custom.