Allow suppressing warning when overwriting env variable
anuraaga opened this issue · comments
TL;DR
Currently, a warning is always emitted when overwriting an env var. This will happen easily when using the action twice in the same workflow.
https://github.com/google-github-actions/auth/blob/main/src/main.ts#L302
There are workflows where this makes sense though, for example when running e2e tests against one project and then pushing an image to another. It would be nice if there was an option to suppress this warning where it is expected behavior. Alternatively, removing the warning would fix the problem too - I noticed it was added in #157 which was about flagging out variable export, but I don't see any mention of a user request or motivation for the warning. Does't mean it shouldn't be there, just trying to link for the history - I think it's worth considering leaving out an additional option and only logging a warning in ACTIONS_STEP_DEBUG mode.
Detailed design
with:
allow_overwriting_environment: true
or perhaps a polymorphic type for the current one
with:
export_environment_variables: overwrite
When overwrite
, it is the same as true
but suppresses the warning.
or check ACTIONS_STEP_DEBUG
and log the warning when true without any additional option.
Additional information
No response
Hi there @anuraaga 👋!
Thank you for opening an issue. Our team will triage this as soon as we can. Please take a moment to review the troubleshooting steps which lists common error messages and their resolution steps.
Hi @anuraaga - the warning is just that, a warning. If you know what you're doing and it's intentional, you can ignore the warning.
CIs are a shared system, even if the author of a workflow may understand the nature of a warning, other members looking at the workflow result will be confused by warnings being raised. Having a clean build without warnings is important for maintaining shared systems I think. Isn't it a bit hasty to just close the issue without considering the UX?
Thanks for the context @sethvargo. Also for anyone else that may find this issue, I noticed that the check for the warning is truthiness, so while it doesn't seem possible to remove already set env vars in a github action, setting to empty string worked fine to suppress the warnings. This sort of step can do it
- shell: bash
run: |
echo "CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE=" >> $GITHUB_ENV
echo "GOOGLE_APPLICATION_CREDENTIALS=" >> $GITHUB_ENV
echo "GOOGLE_GHA_CREDS_PATH=" >> $GITHUB_ENV
echo "CLOUDSDK_CORE_PROJECT=" >> $GITHUB_ENV
echo "CLOUDSDK_PROJECT=" >> $GITHUB_ENV
echo "GCLOUD_PROJECT=" >> $GITHUB_ENV
echo "GCP_PROJECT=" >> $GITHUB_ENV
echo "GOOGLE_CLOUD_PROJECT=" >> $GITHUB_ENV