Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow suppressing warning when overwriting env variable #326

Closed
anuraaga opened this issue Sep 7, 2023 · 5 comments
Closed

Allow suppressing warning when overwriting env variable #326

anuraaga opened this issue Sep 7, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@anuraaga
Copy link

anuraaga commented Sep 7, 2023

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

@anuraaga anuraaga added the enhancement New feature or request label Sep 7, 2023
@github-actions
Copy link

github-actions bot commented Sep 7, 2023

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.

@sethvargo
Copy link
Member

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.

@anuraaga
Copy link
Author

anuraaga commented Sep 8, 2023

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?

@sethvargo
Copy link
Member

Hi @anuraaga - thank you for the reply. We have considered the UX, as this has been discussed ad nauseam in #156 and #295. It didn't seem necessary to rehash all of those conversations. Sorry if it seemed hasty.

@anuraaga
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants