No description
Find a file
gurusai-voleti 01af06c41d
chore: Migrate gsutil usage to gcloud storage (#733)
Automated: Migrate {target_path} from gsutil to gcloud storage

This CL is part of the on going effort to migrate from the legacy
`gsutil` tool to the new and improved `gcloud storage` command-line
interface.
`gcloud storage` is the recommended and modern tool for interacting with
Google Cloud Storage, offering better performance, unified
authentication, and a more consistent command structure with other
`gcloud` components. 🚀

### Automation Details

This change was **generated automatically** by an agent that targets
users of `gsutil`.
The transformations applied are based on the [gsutil to gcloud storage
migration guide](http://go/gsutil-gcloud-storage-migration-guide).

### ⚠️ Action Required: Please Review and Test Carefully

While we have based the automation on the migration guide, every use
case is unique.
**It is crucial that you thoroughly test these changes in environments
appropriate to your use-case before merging.**
Be aware of potential differences between `gsutil` and `gcloud storage`
that could impact your workflows.
For instance, the structure of command output may have changed,
requiring updates to any scripts that parse it. Similarly, command
behavior can differ subtly; the `gcloud storage rsync` command has a
different file deletion logic than `gsutil rsync`, which could lead to
unintended file deletions.

Our migration guides can help guide you through a list of mappings and
some notable differences between the two tools.

Standard presubmit tests are run as part of this CL's workflow. **If you
need to target an additional test workflow or require assistance with
testing, please let us know.**

Please verify that all your Cloud Storage operations continue to work as
expected to avoid any potential disruptions in production.

### Support and Collaboration

The `GCS CLI` team is here to help! If you encounter any issues, have a
complex use case that this automated change doesn't cover, or face any
other blockers, please don't hesitate to reach out.
We are happy to work with you to test and adjust these changes as
needed.

**Contact:** `gcs-cli-hyd@google.com`

We appreciate your partnership in this important migration effort!

#gsutil-migration

Signed-off-by: gurusai-voleti <gvoleti@google.com>
2026-04-07 15:12:47 -04:00
.github Do not use the tool-cache by default (#724) 2025-08-24 21:51:10 -04:00
dist Release: v3.0.1 (#729) 2025-08-28 13:37:35 +00:00
src Update to use v3 references (#725) 2025-08-24 21:54:52 -04:00
tests Update deps (#677) 2024-01-22 20:51:08 -05:00
.gitignore docs: update references from master -> main (#544) 2022-04-05 11:04:56 -04:00
.prettierrc.js Update deps (#691) 2024-08-05 16:11:33 -04:00
action.yml Update to use v3 references (#725) 2025-08-24 21:54:52 -04:00
CHANGELOG.md update release process (#562) 2022-05-27 12:15:40 -04:00
CODEOWNERS chore: Create CODEOWNERS (#268) 2021-02-12 11:16:36 -06:00
eslint.config.mjs Update deps (#691) 2024-08-05 16:11:33 -04:00
LICENSE docs: update README (#241) 2020-11-18 11:33:53 -08:00
package-lock.json Release: v3.0.1 (#729) 2025-08-28 13:37:35 +00:00
package.json Release: v3.0.1 (#729) 2025-08-28 13:37:35 +00:00
README.md chore: Migrate gsutil usage to gcloud storage (#733) 2026-04-07 15:12:47 -04:00
tsconfig.json Update deps (#716) 2025-07-18 16:02:58 -04:00

setup-gcloud GitHub Action

Configures the Google Cloud SDK in the GitHub Actions environment. The Google Cloud SDK includes the gcloud binary.

Or integrate natively with other Google Cloud GitHub Actions:

This is not an officially supported Google product, and it is not covered by a Google Cloud support contract. To report bugs or request features in a Google Cloud product, please contact Google Cloud support.

Prerequisites

  • This action requires Google Cloud credentials to execute gcloud commands. See Authorization for more details.

  • This action runs using Node 24. If you are using self-hosted GitHub Actions runners, you must use a runner version that supports this version or newer.

Usage

jobs:
  job_id:
    # Add "id-token" with the intended permissions.
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v2'
      with:
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
        service_account: 'my-service-account@my-project.iam.gserviceaccount.com'

    - name: 'Set up Cloud SDK'
      uses: 'google-github-actions/setup-gcloud@v3'
      with:
        version: '>= 363.0.0'

    - name: 'Use gcloud CLI'
      run: 'gcloud info'

Inputs

  • version: (Optional, default: latest) A string representing the version or version constraint of the Cloud SDK (gcloud) to install (e.g. "290.0.1" or ">= 197.0.1"). The default value is "latest", which will always download and install the latest available Cloud SDK version.

    - uses: 'google-github-actions/setup-gcloud@v3'
      with:
        version: '>= 416.0.0'
    

    If there is no installed gcloud version that matches the given constraint, this GitHub Action will download and install the latest available version that still matches the constraint.

    Authenticating via Workload Identity Federation requires version 363.0.0 or newer. If you need support for Workload Identity Federation, specify your version constraint as such:

    - uses: 'google-github-actions/setup-gcloud@v3'
      with:
        version: '>= 363.0.0'
    

    You are responsible for ensuring the gcloud version matches the features and components required.

  • project_id: (Optional) ID of the Google Cloud project. If provided, this will configure gcloud to use this project ID by default for commands. Individual commands can still override the project using the --project flag which takes precedence. If unspecified, the action attempts to find the "best" project ID by looking at other inputs and environment variables.

  • install_components: (Optional) List of additional gcloud components to install, specified as a comma-separated list of strings:

    install_components: 'alpha,cloud-datastore-emulator'
    
  • skip_install: (Optional) Skip installation of gcloud and use the system-supplied version instead. If specified, the version input is ignored.

    ⚠️ You will not be able to install additional gcloud components, because the system installation is locked.

  • cache: (Optional) Transfer the downloaded artifacts into the runner's tool cache. On GitHub-managed runners, this have very little impact since runneres are ephemeral. On self-hosted runners, this could improve future runs by skipping future gcloud installations.

Outputs

  • version: Version of gcloud that was installed.

Authorization

The setup-gcloud action installs the Cloud SDK (gcloud). To configure its authentication to Google Cloud, you must first use the google-github-actions/auth action. The auth action sets Application Default Credentials, then the setup-gcloud action references these credentials to configure gcloud credentials . You can authenticate via the following options:

Workload Identity Federation (preferred)

⚠️ You must use the Cloud SDK version 390.0.0 or later to authenticate the bq tool.

jobs:
  job_id:
    # Add "id-token" with the intended permissions.
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v2'
      with:
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
        service_account: 'my-service-account@my-project.iam.gserviceaccount.com'

    - name: 'Set up Cloud SDK'
      uses: 'google-github-actions/setup-gcloud@v3'

    - name: 'Use gcloud CLI'
      run: 'gcloud info'

Service Account Key JSON

jobs:
  job_id:
    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v2'
      with:
        credentials_json: '${{ secrets.GCP_CREDENTIALS }}'

    - name: 'Set up Cloud SDK'
      uses: 'google-github-actions/setup-gcloud@v3'

    - name: 'Use gcloud CLI'
      run: 'gcloud info'

Self-hosted runners on Google Cloud Platform

If you are using self-hosted runners that are hosted on Google Cloud Platform, credentials are automatically obtained from the service account attached to the runner. In this scenario, you do not need to run the google-github-actions/auth action.

jobs:
  job_id:
    steps:
    - name: 'Set up Cloud SDK'
      uses: 'google-github-actions/setup-gcloud@v3'

    - name: 'Use gcloud CLI'
      run: 'gcloud info'

Multiple Service Accounts

To use multiple service accounts, a second auth step is required to update the credentials before using setup-gcloud:

jobs:
  job_id:
    # Add "id-token" with the intended permissions.
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
      - id: 'auth service account 1'
        uses: 'google-github-actions/auth@v2'
        with:
          workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
          service_account: 'service-account-1@my-project.iam.gserviceaccount.com'

      - name: 'Set up Cloud SDK'
        uses: 'google-github-actions/setup-gcloud@v3'

      - name: 'Use gcloud CLI'
        run: 'gcloud auth list --filter=status:ACTIVE --format="value(account)"'
        # service-account-1@my-project.iam.gserviceaccount.com

      - id: 'auth service account 2'
        uses: 'google-github-actions/auth@v2'
        with:
          credentials_json: '${{ secrets.GCP_CREDENTIALS }}'

      - name: 'Set up Cloud SDK'
        uses: 'google-github-actions/setup-gcloud@v3'

      - name: 'Use gcloud CLI'
        run: 'gcloud auth list --filter=status:ACTIVE --format="value(account)"'
        # service-account-2@my-project.iam.gserviceaccount.com

Versioning

We recommend pinning to the latest available major version:

- uses: 'google-github-actions/setup-gcloud@v3'

While this action attempts to follow semantic versioning, but we're ultimately human and sometimes make mistakes. To prevent accidental breaking changes, you can also pin to a specific version:

- uses: 'google-github-actions/setup-gcloud@v3.0.0'

However, you will not get automatic security updates or new features without explicitly updating your version number. Note that we only publish MAJOR and MAJOR.MINOR.PATCH versions. There is not a floating alias for MAJOR.MINOR.