💸Save up to $132K/month in CI costs!👉 Try Free
Skip to main content
← Back to workflows

How to Authenticate to Google Cloud from GitHub Actions

google-github-actions-auth -
GitHub Action

Optimize Your CI/CD Pipeline

Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.

45% Faster Builds
60% Cost Reduction
Usage
name: 'Usage of auth GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: 'google-github-actions/auth@v2'
with:
project_id: 'my-project'
workload_identity_provider: >
'projects/12/locations/global/workloadIdentityPools/pool/providers/provider'

auth logo

Authenticate to Google Cloud

A GitHub Action for authenticating to Google Cloud.


What is Authenticate to Google Cloud GitHub Action?

This GitHub Action authenticate to Google Cloud from GitHub Actions, supporting both Service Account Key JSON and Workload Identity Federation.

Authentication Methods

Service Account Key JSON

Using a Service Account Key JSON file is a straightforward way to authenticate your GitHub Actions with Google Cloud.

- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}

Workload Identity Federation

Workload Identity Federation is a more secure and manageable way to authenticate, especially in multi-cloud environments. Note: This option is not supported by Firebase Admin SDK.

- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected]
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }} # Optional
audience: projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider # Optional