Your app just built flawlessly in GitHub Actions, yet deploying it feels like tossing a dart in the dark. You push a commit, glance at Cloud Run, and wonder if the container gods have smiled. Integrating Cloud Run with GitHub turns that guesswork into a clean, automated handshake, one that removes the drudgery between build and deploy.
Cloud Run excels at running containers serverlessly, scaling fast, and charging only for what you use. GitHub handles version control and collaboration. Together, they form a workflow most developers dream of: containerized apps that go live minutes after code hits main. The trick is wiring identity, permissions, and automation so the pipeline runs securely without constant babysitting.
A GitHub Action can push your build artifacts straight to Google Container Registry, then trigger a Cloud Run deploy using gcloud commands. The key is authentication. Each Action runner must assume a role or identity that Google Cloud accepts. Using Workload Identity Federation, you link GitHub’s OIDC tokens to your Cloud project without storing long-lived service account keys. The result is a deploy that just works, every time, with no shared secrets floating around.
Quick answer: To connect Cloud Run and GitHub securely, use OIDC-based Workload Identity Federation. It maps short-lived GitHub identities to your Google Cloud roles, allowing deployment automation without permanent keys in your repo.
Now, about best practices. Scope those identities tightly. Give each repository only the roles it needs, and rotate policies if your contributors change. Audit logs in Cloud Logging will prove who deployed what, which becomes handy when chasing a bug or prepping for SOC 2 compliance. Having observability at deploy time transforms chaos into a timeline.