Keyless GitHub Actions to Google Cloud with Workload Identity Federation
Authenticate GitHub Actions to Google Cloud without service account keys using Workload Identity Federation. Step-by-step setup with console.

TL;DR
Authenticate GitHub Actions to Google Cloud without service account keys by using Workload Identity Federation, then prove it works by uploading a file to a Cloud Storage bucket.
Time to complete: about 30 minutes
Who it's for: DevOps and platform engineers, and developers who deploy to Google Cloud from GitHub Actions. You should be comfortable with basic IAM and Git.
You'll need: a Google Cloud project where you can create IAM resources, a GitHub repository, and the
gcloudCLI (or Cloud Shell).You'll end up with: a keyless workflow that uploads a folder to a GCS bucket on every push to
main.
Workload Identity Federation (WIF) lets a GitHub Actions workflow authenticate to Google Cloud with a short-lived token, so you never create, download, or rotate a service account key.
A JSON key is a long-lived password sitting in a GitHub secret: if it leaks, anyone can use it until you notice and delete it. With WIF there is nothing to leak. GitHub issues each job a signed OIDC token, Google's Security Token Service (STS) checks it against rules you define, and the job then impersonates a service account that holds only the permissions it needs.
In this guide you will build a small pipeline that uploads the contents of a folder to a Google Cloud Storage (GCS) bucket on every push to main, with no keys anywhere.
How it works
- The workflow runs and GitHub issues it an OIDC token that names the repository, branch, and actor.
- The
authaction sends that token to Google STS. - STS checks the token against the provider's attribute condition. If it matches, it returns a federated token.
- The federated token impersonates the service account, which returns an access token valid for about an hour.
- Later steps use that access token to write to the bucket.
Every credential in this chain is short-lived and minted per run, so there is no standing secret to steal.
Create Workload Identity Pools
The pool is a container for external identities
Console: go to IAM & Admin, then Workload Identity Federation, and click Create pool.
Name: github-action-pool
Description: Workload Identity Federation Pool for GitHub Action
Add the provider
The provider tells Google how to trust GitHub's tokens.
Select a provider: OpenID Connect (OIDC)
Provider name: github-action-provider
Issuer (URL): https://token.actions.githubusercontent.com
Leave other things default and click Continue
Configure provider attributes
Add these attributes by clicking Add mapping
| Google attribute | GitHub token claim | Why you need it |
|---|---|---|
google.subject |
assertion.sub |
Required. Unique identity of the workflow run. |
attribute.actor |
assertion.actor |
The user who triggered the run, useful in audit logs. |
attribute.repository |
assertion.repository |
Lets you grant access to one repo (owner/name). |
attribute.repository_owner |
assertion.repository_owner |
Lets you restrict the whole pool to your account or org. |
Under Attribute conditions, add the rule below, then click Save. assertion.repository_owner=='<GitHub User>'
Create service account
Name: github-action-sa
Description: Service account for GitHub action
Click create and continue
Select the role Storage Object User. It can create, read, overwrite, and delete objects in the bucket
Leave other things default and Click Done
Connect service account for Workload Identity federation
Click on github-action-pool identity pool
Now click on Grant access
Select Grant access using service account impersonation
Select Service account: github-action-sa
Select repository: <github-user>/<repository>
Click Save
This will pop-up for Configure your application
Click Dismiss as we don't need it
Verify the workload identity federation
Now we will create secret and env on GitHub repository and deploy GitHub action to verify the connection between the GitHub and Workload Identity federation in GCP.
Create bucket in GCS
gcloud storage buckets create gs://<unique-bucket-name> \
--location=us-east1 \
--uniform-bucket-level-access
Create this layout.
Note that the folder is workflows (plural); GitHub ignores files in any other folder name.
.
├── .github/
│ └── workflows/
│ └── gcs-upload.yaml
└── file-upload/
└── names.txt
Put any text in file-upload/names.txt; it is the file we will upload.
Create workflow
Here is the workflow for our setup gcs-upload.yaml
name: File upload workflow
run-name: "Upload to GCS"
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
connect-gcp:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
env:
BUCKET: ${{ vars.GCS_BUCKET_NAME }}Select the role Storage Object User. It can create, read, overwrite, and delete objects in the bucketSelect the role Storage Object User. It can create, read, overwrite, and delete objects in the bucketSelect the role Storage Object User. It can create, read, overwrite, and delete objects in the bucket
steps:
- id: 'checkout'
uses: 'actions/checkout@v4'
- id: 'auth'
name: Auth to Google Cloud (WIF)
uses: 'google-github-actions/auth@v3'
with:
workload_identity_provider: ${{ secrets.GCP_WIF_PROVIDER }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
- id: 'upload-files'
name: 'upload files to gcs BUCKET'
uses: 'google-github-actions/upload-cloud-storage@v3'
with:
path: file-upload/
destination: ${{ env.BUCKET }}
parent: false
Three details matter here:
id-token: writeis the permission that lets the job request an OIDC token. Without it theauthstep fails before it ever reaches Google.workload_identity_providerandservice_accountare the only two inputs theauthaction needs. There is nocredentials_json, which is the point.parent: falseuploads the folder's contents to the bucket root instead of creating afile-upload/prefix.
To get WIF provider resource name:
gcloud iam workload-identity-pools providers describe github-action-provider \
--location="global" \
--workload-identity-pool="github-action-pool" \
--format="value(name)"
The output looks like this:
projects/123456789012/locations/global/workloadIdentityPools/github-action-pool/providers/github-action-provider
To get Service account email:
gcloud iam service-accounts list \
--filter="email:github-action-sa@" \
--format="value(email)"
The service account email follows the pattern
github-action-sa@<project-id>.iam.gserviceaccount.com.
Create secrets and variables on GtiHub
In your repository, go to Settings, then Secrets and variables, then Actions, open the Secrets tab, and add:
Secrets:
| Name | Secret |
|---|---|
GCP_WIF_PROVIDER |
The provider resource name from the command above |
GCP_SA_EMAIL |
github-action-sa@<project-id>.iam.gserviceaccount.com |
Variables:
| Name | Value |
|---|---|
GCS_BUCKET_NAME |
Use the same bucket name |
Push code
deploy workflow on GitHub
git add .
git commit -m "Feat: gcs-upload workflow"
git push origin main
Verify the deployment
Check the GitHub success message
Verify that file is uploaded on GCS bucket
Conclusion
You now have a GitHub Actions workflow that reaches Google Cloud through a short-lived, repository-scoped identity instead of a stored key. The same pattern works for any GCP service the service account is allowed to use, such as Artifact Registry, Cloud Run, or Terraform state buckets.
Reference:
Official Authenticate to Google Cloud from GitHub Actions: https://github.com/google-github-actions/auth
Last tested: Nov 2026
About the author
- Senior Cloud & DevOps Engineer with 7.5+ years of experience designing immutable infrastructure, GKE platforms, GitOps pipelines, and FinOps optimizations on Google Cloud. Founder at ShellScriptLab (shellscriptlabs.com).
Comments
Join the discussionNo comments yet. Be the first to comment.
Google Cloud Architecture & Security
Production patterns for GCP architecture, IAM hardening, Workload Identity Federation, Cloud Storage, and multi-account local setups.





