google-github-actions / auth

A GitHub Action for authenticating to Google Cloud.

Home Page:https://cloud.google.com/iam

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable warning ¨Did you forget to use "actions/checkout" before this step?¨

kopax-polyconseil opened this issue · comments

TL;DR

Add feature to disable warning ¨Did you forget to use "actions/checkout" before this step?¨

Detailed design

add inputs checkout-warning

When false, do not emit warning

Additional information

image

It creates a lot of noise =/

Hi there @kopax-polyconseil 👋!

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.

Please provide your action.yml? What are you doing that requires the auth action but not persisted credentials?

It is a private repository in charge of doing a dump restore, unfortunately.

It is mainly gcloud commands to create the instance, restore backup, etc... we do not need to checkout anything.

I think I now see your point, do you mean I can most likely set persist_credentials: false ?

What we do that needs credentials:

  • kubectl commands / k8s
  • gcloud cli commands
  • http gcloud api curl commands
  • terragrunt commands

Hi @kopax-polyconseil - then the error message is working as intended. You need to run actions/checkout before auth in order to create the shared directory where the credentials will be stored to be accessible by the subsequent steps.

If you set persist_credentials to false, then no credentials will be persisted across steps. The filesystem is the only shared "state" across steps in a job.

How are you passing the credentials into those kubectl/gcloud commands?

@sethvargo

image

With this step, I do not need to checkout, I just want to disable some cronjobs in k8s. As soon as I add persist_credentials: false, I can't use any commands.

However, if I don't add persist_credentials: false AND I DO NOT use @actions/checkout, then it work. However, I do have those warnings which I want to disable.

It appears to me that the features request have sens as the checkout is unecessary step in my workflow ?

Also, I would like to get your opinion: Could you please explain the interest of using this action with persist_credentials: false (use case, ...) ?

I can also found a related issue here : #335

Thanks in advance !

With this step, I do not need to checkout, I just want to disable some cronjobs in k8s.

You may not need the files, but the auth action needs somewhere to store credentials, and it stores them in the checked-out workspace. If that workspace does not exist, there is nowhere for the credential file to be stored. Remember that auth is creating a credentials file and exporting the necessary environment variables downstream to find that credential - the credential has to exist somewhere on disk.

As soon as I add persist_credentials: false, I can't use any commands.

That makes sense - if you do not persist the credential, it will not be available in later steps.

However, if I don't add persist_credentials: false AND I DO NOT use @actions/checkout, then it work. However, I do have those warnings which I want to disable.

That should not work. If it's working, that's not a supported workflow and could break at any time. This is not our doing, but GitHub Actions'.

It appears to me that the features request have sens as the checkout is unecessary step in my workflow ?

GitHub Actions has a tendency of introducing and changing behaviors in an undocumented way. I would strongly suggest adding actions/checkout as a prior step. You can limit the checkout by setting the clone depth to speed things up. Alternatively, you can manually create $GITHUB_WORKSPACE.

Could you please explain the interest of using this action with persist_credentials: false (use case, ...) ?

The auth action can provide credentials as an output (an OAuth 2.0 Access Token or an OIDC token). If you are not using Application Default Credentials (ADC), you can skip the credential export and use the generated token instead. This is an advanced use case, which is why the default option is true.