setup-gcloud icon indicating copy to clipboard operation
setup-gcloud copied to clipboard

gsutil requires a project id

Open mchirico opened this issue 6 years ago • 2 comments

When running gsutil in an action.yml file, an error is thrown requiring a project id during configuration.

    - run: |
        # View storage
        gsutil ls

You are attempting to perform an operation that requires a project id, with none configured. Please re-run gsutil config and make sure to follow the instructions for finding and entering your default project id.

However if gcloud is activated with a valid project_id, then, the gsutil command works correctly. For example, like the following:

gcloud auth activate-service-account --project=${someProject_id} --key-file=${tmpKeyFilePath}`

The problem may be here https://github.com/GoogleCloudPlatform/github-actions/blob/2a9cbc618184da4718e0d16a1b0a055a4f90f66e/setup-gcloud/src/setup-gcloud.ts#L84

Note there is no --project, which could be picked up from the key-file.

mchirico avatar Feb 28 '20 01:02 mchirico

I think you should run

gsutil ls -p my-project

in your action to make it explicit. Depending on the type of service account, we may not be able to extract the project ID. Furthermore, you may be using a service account in project A but have access to buckets in project B. It feels a little too magical and thus I think explicitly saying the project (via -p) might be better. WDYT?

sethvargo avatar Mar 02 '20 09:03 sethvargo

gcloud config set project [projectID]

pavneetsinghkohli avatar Sep 29 '22 08:09 pavneetsinghkohli