Skip to content
Latchkey

How to Deploy a Container to Cloud Run From Source in GitHub Actions

gcloud run deploy --source hands your source to Cloud Build, which builds the image and deploys it to Cloud Run in one command.

Skip a separate build step: gcloud run deploy --source . uploads the repo, builds with buildpacks or your Dockerfile via Cloud Build, pushes to Artifact Registry, and deploys the new revision.

Steps

  • Authenticate via WIF and set up gcloud.
  • Run gcloud run deploy <service> --source ..
  • Pass --region and --allow-unauthenticated as needed.

Workflow

.github/workflows/deploy.yml
permissions:
  id-token: write
  contents: read
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: google-github-actions/auth@v2
        with:
          workload_identity_provider: ${{ vars.WIF_PROVIDER }}
          service_account: ${{ vars.DEPLOY_SA }}
      - uses: google-github-actions/setup-gcloud@v2
      - run: |
          gcloud run deploy web \
            --source . \
            --region us-central1 \
            --allow-unauthenticated

Gotchas

  • The account needs roles/cloudbuild.builds.editor and access to the default Cloud Build bucket.
  • First deploy may prompt to create an Artifact Registry repo; pre-create it to keep CI non-interactive.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →