No description
Find a file
2021-12-22 13:54:04 -06:00
.github Revert "Rename workflows and branches to main (#449)" (#452) 2021-12-22 12:54:08 -06:00
dist chore: build dist (#424) 2021-12-06 14:21:19 -06:00
example-workflows Revert "Rename workflows and branches to main (#449)" (#452) 2021-12-22 12:54:08 -06:00
src fix: support export auth export with envvar for backwards compat (#426) 2021-12-22 11:10:44 -06:00
tests fix: support export auth export with envvar for backwards compat (#426) 2021-12-22 11:10:44 -06:00
.eslintrc.js feat: Export credentials into RUNNER_TEMP instead of GITHUB_WORKSPACE (#405) 2021-11-30 16:04:23 -06:00
.gitignore Revert "Rename workflows and branches to main (#449)" (#452) 2021-12-22 12:54:08 -06:00
.prettierrc.js feat: Export credentials into RUNNER_TEMP instead of GITHUB_WORKSPACE (#405) 2021-11-30 16:04:23 -06:00
action.yml Revert back to using GITHUB_WORKSPACE for storing credentials (#412) 2021-12-01 11:30:44 -06:00
CHANGELOG.md chore: release 0.3.0 (#338) 2021-12-06 14:52:35 -06:00
CODEOWNERS chore: Create CODEOWNERS (#268) 2021-02-12 11:16:36 -06:00
CONTRIBUTING.md docs: update README (#241) 2020-11-18 11:33:53 -08:00
LICENSE docs: update README (#241) 2020-11-18 11:33:53 -08:00
package-lock.json chore: update deps and switch to @vercel/ncc (#456) 2021-12-22 13:54:04 -06:00
package.json chore: update deps and switch to @vercel/ncc (#456) 2021-12-22 13:54:04 -06:00
README.md Update README to push more towards v0 (#454) 2021-12-22 13:15:06 -06:00
tsconfig.json feat: Export credentials into RUNNER_TEMP instead of GITHUB_WORKSPACE (#405) 2021-11-30 16:04:23 -06:00

setup-gcloud GitHub Action

Configures the Google Cloud SDK in the GitHub Actions environment. The Google Cloud SDK includes both the gcloud and gsutil binaries.

Or integrate natively with other Google Cloud GitHub Actions:

📢 NOTICES

  • Do not pin this action to @master, use @v0 instead. We are going to rename the branch to main in 2022 and this will break existing workflows. See Versioning for more information.

  • Previously this repository contained the code for ALL of the GCP GithHub Actions. Now each action has it's own repo and this repo is only for setup-gcloud.

    For setup-gcloud:

    steps:
    - id: gcloud
    -  uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
    +  uses: google-github-actions/setup-gcloud@v0
    

    For other actions (example uses deploy-cloudrun):

    steps:
    - id: deploy
    -  uses: GoogleCloudPlatform/github-actions/deploy-cloudrun@master
    +  uses: google-github-actions/deploy-cloudrun@v0
    

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@v0'
      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@v0'

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

Inputs

Name Requirement Default Description
version optional latest The version of the gcloud to be installed. Example: 290.0.1
project_id optional ID of the Google Cloud Platform 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.
service_account_email optional Service account email address to use for authentication. This is required for legacy .p12 keys but can be omitted for JSON keys. This is usually of the format <name>@<project-id>.iam.gserviceaccount.com.
export_default_credentials optional false Exports the path to Default Application Credentials as the environment variable GOOGLE_APPLICATION_CREDENTIALS to be available in later steps. Google Cloud services automatically use this environment variable to find credentials.
credentials_file_path optional (temporary file) Only valid when export_default_credentials is true. Sets the path at which the credentials should be written.
cleanup_credentials optional true If true, the action will remove any generated credentials from the filesystem upon completion.
service_account_key optional (Deprecated) This input is deprecated. See auth section for more details. The service account key which will be used for authentication credentials. This key should be created and stored as a secret. It can be encoded as a Base64 string or as JSON.

Example Workflows

Authorization

This action installs the Cloud SDK (gcloud). To configure its authentication to Google Cloud, use the google-github-actions/auth action. You can authenticate via:

Workload Identity Federation (preferred)

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

    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v0'
      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@v0'

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

Service Account Key JSON

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

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

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

Application Default Credentials

If and only if you are using self-hosted runners that are hosted on Google Cloud Platform, the Cloud SDK will automatically authenticate using the machine credentials:

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

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

Versioning

We recommend pinning to the latest available major version:

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

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@v0.1.1'

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.

Contributing

See CONTRIBUTING.

License

See LICENSE.