WIF doesn't work with all versions of gcloud

This issue has been tracked since 2022-01-11.

TL;DR

I'm updating our github actions to use WIF, I've spent ages trying to figure out why it wasn't working, the only error was

Error: google-github-actions/setup-gcloud failed with: The process '/opt/hostedtoolcache/gcloud/315.0.0/x64/bin/gcloud' failed with exit code 2

I looked at the raw logs, no additional details. The error wasn't on the google-github-actions/auth step, was on the google-github-actions/setup-gcloud step.

Turns out older versions of gcloud don't use WIF tokens. This is what I had and what worked.

...
      - id: 'auth'
        uses: 'google-github-actions/[email protected]'
        with:
          workload_identity_provider: 'projects/{project_id}/locations/global/workloadIdentityPools/{pool_id}/providers/{provider_id}'
          service_account: '{service_account_name}@{project_name}.iam.gserviceaccount.com'

      - name: 'Setup gcloud SDK'
        uses: google-github-actions/[email protected]
        with:
          version: "315.0.0"  # doesn't work with WIF (assume this version of gcloud doesn't know where/how to look for a WIF token)
          version: "367.0.0" # works
...

Please add something to the README.md to help others in this situation, perhaps under https://github.com/google-github-actions/setup-gcloud#usage, eg

...
      - name: 'Set up Cloud SDK'
         uses: 'google-github-actions/[email protected]'
+       with:  # optional
+            version: "???.0.0" # min version of gcloud that works with WIF
...

Expected behavior

WIF would work

Observed behavior

Error: google-github-actions/setup-gcloud failed with: The process '/opt/hostedtoolcache/gcloud/315.0.0/x64/bin/gcloud' failed with exit code 2

Action YAML

See above

Additional information

I assumed that the WIF token was in a place and format that gcloud would find and simply pass to gcp.

sethvargo wrote this answer on 2022-01-11

363.0.0 is the minimum version. Will be fixed with #476.

More Details About Repo
Owner Name google-github-actions
Repo Name setup-gcloud
Full Name google-github-actions/setup-gcloud
Language TypeScript
Created Date 2019-11-05
Updated Date 2023-03-23
Star Count 1505
Watcher Count 65
Fork Count 548
Issue Count 11

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date