I haven't worked with these particular GitHub Actions myself, but two things that you could try: Looking at google-github-actions/setup-gcloud, the latest version appears to be v2.1.1. ( https://github.com/google-github-actions/setup-gcloud/tags ). Perhaps it is worth trying v2.1.1 rather than v0.2.1 which is 3+ years old. Potentially, there are speed improvements there. For the Docker container building process, you'd have to review the Dockerfile and see whether you can perform any optimizations. Can you remove unnecessary dependencies? Can you utilize multi-stage builds to decrease the image size? ( https://docs.docker.com/build/building/multi-stage/ ) Answer from FlatPerformer on reddit.com
🌐
GitHub
github.com › google-github-actions › setup-gcloud
GitHub - google-github-actions/setup-gcloud: A GitHub Action for installing and configuring the gcloud CLI. · GitHub
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: ⚠️ You must use the Cloud SDK version 390.0.0 ...
Starred by 1.9K users
Forked by 527 users
Languages   TypeScript 95.3% | JavaScript 4.7%
🌐
GitHub
github.com › marketplace › actions › set-up-gcloud-cloud-sdk-environment
Set up gcloud Cloud SDK environment · Actions · GitHub Marketplace · GitHub
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: ⚠️ You must use the Cloud SDK version 390.0.0 ...
Discussions

Github actions to google cloud run takes about 7 mins. Is that normal?
I haven't worked with these particular GitHub Actions myself, but two things that you could try: Looking at google-github-actions/setup-gcloud, the latest version appears to be v2.1.1. ( https://github.com/google-github-actions/setup-gcloud/tags ). Perhaps it is worth trying v2.1.1 rather than v0.2.1 which is 3+ years old. Potentially, there are speed improvements there. For the Docker container building process, you'd have to review the Dockerfile and see whether you can perform any optimizations. Can you remove unnecessary dependencies? Can you utilize multi-stage builds to decrease the image size? ( https://docs.docker.com/build/building/multi-stage/ ) More on reddit.com
🌐 r/devops
9
9
October 1, 2024
google cloud platform - Github Actions Failing for setup-gcloud - Stack Overflow
My previous deployments with same github workflow file were successful. Suddenly today, I get this error in Github Actions while trying to deploy. May I know how to fix this? Run google-github-acti... More on stackoverflow.com
🌐 stackoverflow.com
Setting up gcloud takes more than a minute on GitHub Runners
- name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 with: install_components: 'kubectl,skaffold' More on github.com
🌐 github.com
30
January 28, 2025
documentation misleading for Application Default Credentials
name: wif-ci on: [push, pull_request, ...ions/auth@v2' with: workload_identity_provider: 'projects/$NUMBER/locations/global/workloadIdentityPools/$POOL/providers/$PROVIDER' service_account: '$SA_EMAIL' - name: 'Set up Cloud SDK' uses: 'google-github-actions/setup-gcloud@v2' with: ... More on github.com
🌐 github.com
4
April 4, 2024
🌐
GitHub
github.com › google-github-actions › setup-gcloud › blob › main › action.yml
setup-gcloud/action.yml at main · google-github-actions/setup-gcloud
- uses: 'google-github-actions/setup-gcloud@v2' 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 ·
Author   google-github-actions
🌐
Reddit
reddit.com › r/devops › github actions to google cloud run takes about 7 mins. is that normal?
r/devops on Reddit: Github actions to google cloud run takes about 7 mins. Is that normal?
October 1, 2024 -

Hi everyone, am new to ci/cd and am trying to automate a deployment of an api (written in nodejs) and deploy it as a Google Cloud Run upon a commit made to GitHub "main" branch.

Currently am using the below script for the requirement and running on GitHub Actions. However it seems to be taking approximately 7 mins in total (3.5 mins to 'setup Google Cloud SDK' & 3.5 min to 'build and push container' ) for the workflow to complete running.

Am wondering if that is normal or is there anyway to reduce the time taken to run it?

jobs: deploy: runs-on: ubuntu-latest

steps:
  - name: Checkout code
    uses: actions/checkout@v3

  - name: Setup Google Cloud SDK
    uses: google-github-actions/setup-gcloud@v0.2.1
    with:
      project_id: ${{ secrets.GCP_PROJECT_ID }}
      service_account_key: ${{ secrets.GCP_SA_KEY }}
      export_default_credentials: true

  - name: Authorize Docker push
    run: gcloud auth configure-docker

  - name: Build and Push Container
    run: |-
      gcloud builds submit --gcs-log-dir $BUILD_LOGS_BUCKET --tag gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }}

  - name: Deploy to Cloud Run
    run: |-
      gcloud run deploy $SERVICE_NAME \
        --region $REGION \
        --image gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} \
        --platform managed \
        --allow-unauthenticated
Top answer
1 of 4
11
I haven't worked with these particular GitHub Actions myself, but two things that you could try: Looking at google-github-actions/setup-gcloud, the latest version appears to be v2.1.1. ( https://github.com/google-github-actions/setup-gcloud/tags ). Perhaps it is worth trying v2.1.1 rather than v0.2.1 which is 3+ years old. Potentially, there are speed improvements there. For the Docker container building process, you'd have to review the Dockerfile and see whether you can perform any optimizations. Can you remove unnecessary dependencies? Can you utilize multi-stage builds to decrease the image size? ( https://docs.docker.com/build/building/multi-stage/ )
2 of 4
3
This should be helpful Optimize SDK Setup (Target: Under 1 minute) Caching Google Cloud SDK: By caching the SDK, you avoid downloading and installing it every time. name: Cache Google Cloud SDK uses: actions/cache@v3 with: path: /opt/hostedtoolcache/gcloud key: ${{ runner.os }}-gcloud-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-gcloud- Prebuilt Image: Use a prebuilt Docker image that already includes the Google Cloud SDK. This avoids the installation time altogether: runs-on: ubuntu-latest container: image: google/cloud-sdk:latest ==> This skips the SDK setup step, bringing the time down significantly. 2. Speed Up Docker Build and Push (Target: 1-1.5 minutes) Layer Caching in Google Cloud Build: Enable caching in Cloud Build by adding caching flags when submitting the build: name: Build and Push Container with Cache run: | gcloud builds submit --gcs-log-dir $BUILD_LOGS_BUCKET --tag gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} --cache="true" Optimize Dockerfile: Use lightweight base images like node:alpine. Minimize the number of layers in the Dockerfile by combining commands where possible. Use multi-stage builds to reduce final image size if necessary. FROM node:alpine AS builder WORKDIR /app COPY . . RUN npm install RUN npm run build FROM node:alpine WORKDIR /app COPY --from=builder /app . CMD ["npm", "start"] Use Pre-built or Smaller Images: If you have a very static application, use a pre-built image for certain layers or choose a smaller, optimized image to reduce build time. Faster Deployment to Cloud Run (Target: Under 1 minute) Use Smaller Container Images: By reducing your image size (through the steps above), you can push and deploy much faster. Split the Build and Deploy Steps: If the build is more expensive in time than the deployment, you could potentially parallelize these steps or split them across different actions: name: Deploy to Cloud Run run: | gcloud run deploy $SERVICE_NAME --region $REGION --image gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} --platform managed --allow-unauthenticated --no-traffic Parallelize Docker Push and Deployment: You might be able to parallelize certain tasks such as authorization and deployment to shave off time. Final Optimized Workflow: Here’s a consolidated view of what the GitHub Action might look like after optimization: jobs: deploy: runs-on: ubuntu-latest container: image: google/cloud-sdk:latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Authorize Docker push run: gcloud auth configure-docker - name: Build and Push Container with Cache run: | gcloud builds submit \ --gcs-log-dir $BUILD_LOGS_BUCKET \ --tag gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} \ --cache="true" - name: Deploy to Cloud Run run: | gcloud run deploy $SERVICE_NAME \ --region $REGION \ --image gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} \ --platform managed \ --allow-unauthenticated With these optimizations, it’s possible to reduce the runtime to around 3 minutes, but the exact time might vary depending on network conditions, container complexity, and caching effectiveness.
🌐
Nikhil Rao's Blog
nikhilrao.blog › automating-google-cloud-with-github-actions-using-gcloud-cli
Automating Google Cloud with GitHub Actions using gcloud CLI
May 14, 2025 - name: GCP Deployment on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - id: 'auth' uses: 'google-github-actions/auth@v2' with: credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}' - name: 'Set up Cloud SDK' uses: 'google-github-actions/setup-gcloud@v2' - name: 'Use gcloud CLI' run: 'gcloud info'
🌐
CICube
cicube.io › home › workflow hub › how to configure google cloud sdk in github action?
How to Configure Google Cloud SDK in GitHub Action? - Workflow Hub - CI Cube
May 10, 2024 - jobs: job_id: permissions: contents: 'read' id-token: 'write' steps: - id: 'auth' uses: 'google-github-actions/auth@v2' with: workload_identity_provider: 'projects/123/locations/global/workloadIdentityPools/pool/providers' service_account: '[email protected]' - name: 'Set up Cloud SDK' uses: 'google-github-actions/setup-gcloud@v2' - name: 'Use gcloud CLI' run: 'gcloud info'
🌐
Alexander Hose
alexanderhose.com › how-to-integrate-github-actions-with-google-cloud-platform
How to Integrate GitHub Actions with Google Cloud Platform
April 11, 2025 - - name: 'Authenticate with GCP' id: auth uses: 'google-github-actions/auth@v2' with: project_id: 'security-alexanderhose' workload_identity_provider: 'projects/243190957191/locations/global/workloadIdentityPools/github-actions-provider/providers/github-actions-pool' Set Up Cloud SDK: This step uses the google-github-actions/setup-gcloud@v2 action to set up the Google Cloud SDK, enabling the use of gcloud commands in subsequent steps.
Find elsewhere
🌐
GitHub
github.com › google-github-actions › setup-gcloud › releases
Releases · google-github-actions/setup-gcloud
August 28, 2025 - Release: v2.2.1 (#722) ## What's Changed * Update deps by @sethvargo in https://github.com/google-github-actions/setup-gcloud/pull/720 * Bump to the latest actions-utils to fix the gen-readme bug by @sethvargo in https://github.com/google-github-actions/setup-gcloud/pull/721 **Full Changelog**: https://github.com/google-github-actions/setup-gcloud/compare/v2.2.0...v2.2.1 ·
Author   google-github-actions
🌐
GitHub
github.com › google-github-actions › setup-cloud-sdk
GitHub - google-github-actions/setup-cloud-sdk: An NPM package for installing and configuring the Google Cloud SDK in GitHub Actions. · GitHub
import * as core from '@actions/core'; import * as toolCache from '@actions/tool-cache'; import * as setupGcloud from '@google-github-actions/setup-cloud-sdk'; // Install gcloud if not already installed.
Starred by 14 users
Forked by 16 users
Languages   TypeScript 92.6% | Go 5.6% | JavaScript 1.8%
🌐
Google Cloud
cloud.google.com › blog › products › devops-sre › using-github-actions-with-google-cloud-deploy
Using GitHub Actions with Google Cloud Deploy | Google Cloud Blog
May 9, 2023 - Next, we’ll use another Google GitHub Action, gcloud-setup, to install and configure the Google Cloud SDK, and configure Docker to use Google Cloud Artifact Registry to store the built images:
🌐
GitHub
github.com › google-github-actions
Google GitHub Actions · GitHub
A GitHub Action for installing and configuring the gcloud CLI. ... A GitHub Action for deploying services to Google Cloud Run. ... A GitHub Action for uploading files to a Google Cloud Storage (GCS) bucket.
🌐
GitHub
github.com › google-github-actions › setup-gcloud › blob › main › README.md
setup-gcloud/README.md at main · google-github-actions/setup-gcloud
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: ⚠️ You must use the Cloud SDK version 390.0.0 ...
Author   google-github-actions
🌐
GitHub
github.com › marketplace › actions › setup-gke-gcloud-auth-plugin
setup-gke-gcloud-auth-plugin · Actions · GitHub Marketplace · GitHub
- name: Authenticate to Google uses: "google-github-actions/auth@v1" with: credentials_json: "${{ secrets.GCP_SERVICEACCOUNT_KEY }}" - uses: simenandre/setup-gke-gcloud-auth-plugin@v1 - name: Authenticate to GKE cluster uses: google-github-actions/get-gke-credentials@v1 with: cluster_name: my_cluster location: europe-west1-b · Migrating to get-gke-credentials can be done like so: - name: Authenticate to Google uses: "google-github-actions/auth@v2" with: credentials_json: "${{ secrets.GCP_SERVICEACCOUNT_KEY }}" - uses: "google-github-actions/setup-gcloud@v2" with: install_components: "gke-gcloud-auth-plugin" - name: Authenticate to GKE cluster uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: my_cluster location: europe-west1-b
🌐
GitHub
github.com › marketplace › actions › setup-google-cloud-sdk
Setup Google Cloud SDK · Actions · GitHub Marketplace · GitHub
This action is not supported by Google Cloud. Proudly maintained by Mathieu Bour, former Vice-CTO @mathrix-education. 2020/11/20: The GoogleCloudPlatform official GitHub organization has deprecated the setup-gcloud action.
🌐
GitHub
github.com › google-github-actions › auth › blob › main › docs › EXAMPLES.md
auth/docs/EXAMPLES.md at main · google-github-actions/auth
jobs: job_id: permissions: contents: 'read' id-token: 'write' steps: - uses: 'actions/checkout@v4' - id: 'auth' uses: 'google-github-actions/auth@v3' with: project_id: 'my-project' workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider' - name: 'Set up Cloud SDK' uses: 'google-github-actions/setup-gcloud@v2'
Author   google-github-actions
🌐
GitHub
github.com › google-github-actions › setup-gcloud › issues › 701
Setting up gcloud takes more than a minute on GitHub Runners · Issue #701 · google-github-actions/setup-gcloud
January 28, 2025 - - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 with: install_components: 'kubectl,skaffold'
Author   AndreasBergmeier6176
🌐
GitHub
github.com › google-github-actions › setup-gcloud › issues › 685
documentation misleading for Application Default Credentials · Issue #685 · google-github-actions/setup-gcloud
April 4, 2024 - name: wif-ci on: [push, pull_request, ...ions/auth@v2' with: workload_identity_provider: 'projects/$NUMBER/locations/global/workloadIdentityPools/$POOL/providers/$PROVIDER' service_account: '$SA_EMAIL' - name: 'Set up Cloud SDK' uses: 'google-github-actions/setup-gcloud@v2' with: ...
Author   eeaton
🌐
Medium
medium.com › @bhpuri › github-actions-series-12-deploy-to-google-cloud-run-with-github-actions-oidc-3e46433645a0
🚀 [GitHub Actions Series #12] Deploy to Google Cloud Run with GitHub Actions + OIDC | by Bharat Puri | Medium
September 20, 2025 - name: Deploy to Google Cloud Run (OIDC) on: push: branches: - main permissions: id-token: write contents: read jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Authenticate to GCP (OIDC) uses: google-github-actions/auth@v2 with: workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} - name: Set up gcloud uses: google-github-actions/setup-gcloud@v2 with: project_id: ${{ secrets.GCP_PROJECT_ID }} - name: Build and push Docker image run: | gcloud builds submit --tag gcr.io/${{ secrets.GCP_PROJECT_ID }}/myapp:latest - name: Deploy to Cloud Run run: | gcloud run deploy myapp \ --image gcr.io/${{ secrets.GCP_PROJECT_ID }}/myapp:latest \ --platform managed \ --region us-central1 \ --allow-unauthenticated ·
Top answer
1 of 1
2

The first thing to do would be to go to the actions and look at the build log and specifically at the failed step (which most likely is going to be function deploying). Look at the error, good chance it is going to tell you what exactly went wrong.

If I had to make an educated guess, I'd say your service account doesn't have enough permissions (mine was setup with two - Cloud Functions Developer role and Service Account User) or the way you deploy the function isn't correct. I see that you are not exporting default credentials when you setup gcloud sdk, is there a reason for that?

Picture worth a thousand words - I've created a simple repo, where I have the most basic (default) python function that I deploy to GCF. Check it out, this should be enough to get you started.

UPDATE:
In case I decide to delete the repo one day, I am going to include the build yaml in here as well:

# This is a basic workflow to help you get started with Actions
name: CI

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      - name: Set up gcloud Cloud SDK environment
        # You may pin to the exact commit or the version.
        # uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
        uses: google-github-actions/[email protected]
        with:
          
          # 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.
          service_account_email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} # optional
          
          # Service account key to use for authentication. This should be the JSON
          # formatted private key which can be exported from the Cloud Console. The
          # value can be raw or base64-encoded.
          service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY }} # 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.
          project_id: ${{ secrets.PROJECT_ID }} # optional
          
          # Export the provided credentials as Google Default Application Credentials.
          # This will make the credentials available to later steps via the
          # GOOGLE_APPLICATION_CREDENTIALS environment variable. Future steps that
          # consume Default Application Credentials will automatically detect and use
          # these credentials.
          export_default_credentials: true # optional



      # Runs a single command using the runners shell
      - name: Deploy the function
        run: gcloud functions deploy myfunc --trigger-http --runtime=python39