This tutorial guides you through deploying the self-hosted GitHub Actions Runners using Google Cloud Shell.
Prerequisites: A GCP project with billing enabled. The Owner role is the easiest option for this tutorial. If the Owner role is not possible, see gcp/README.md for the specific roles required.
Click the Start button to move to the next step.
Select or create a project:
Enable the required APIs:
Set Google Cloud project ID. Replace with your current Google Cloud project ID:
export GOOGLE_CLOUD_PROJECT="<walkthrough-project-id/>"Configure gcloud to use this project:
gcloud config set project "$GOOGLE_CLOUD_PROJECT"
gcloud auth application-default set-quota-project "$GOOGLE_CLOUD_PROJECT"Crucial Step: If you are deploying within an organization (e.g., a company account), certain policies might block public access to Cloud Run.
Check Ingress (Should be allowAll: true):
gcloud org-policies describe "run.allowedIngress" --effective --project="$GOOGLE_CLOUD_PROJECT" --quietIf these are restrictive, you may need to ask your Organization Admin to adjust them or use a project outside the organization. See gcp/README.md for policy details.
The Terraform version pre-installed in Google Cloud Shell is too old. Install a current Terraform version:
curl "https://releases.hashicorp.com/terraform/1.14.5/terraform_1.14.5_linux_amd64.zip" -o "$HOME/terraform.zip"
unzip "$HOME/terraform.zip" terraform -d "$HOME"
export PATH="$HOME:$PATH"Navigate to the gcp directory:
cd gcpCreate a terraform.tfvars file with your configuration.
Google Cloud project ID:
printf 'project_id = "%s"\n' "$GOOGLE_CLOUD_PROJECT" > terraform.tfvars(Optional) Google Cloud region:
echo "region = \"us-central1\"" >> terraform.tfvars(Optional) Google Cloud zone:
echo "zone = \"b\"" >> terraform.tfvarsFor more details, see gcp/README.md. You find there a list of all variables and their default values.
Initialize Terraform:
$HOME/terraform initApply the configuration:
$HOME/terraform apply- Review the plan when prompted.
- Type
yesand press Enter to confirm.
Once Terraform completes successfully, it will output a service_url.
-
Copy the
service_url(e.g.,https://google-cloud-github-runner-xyz-uc.a.run.app). -
Open your browser and navigate to
service_url.Authentication Required: You will be prompted for HTTP Basic Authentication credentials:
- Username:
cloud - Password: Your Google Cloud Project ID
<walkthrough-project-id/>(the value you set inGOOGLE_CLOUD_PROJECT)
- Username:
-
Click Setup GitHub App, then install it on your target Organization or Repository.
Configure your GitHub Actions CI/CD to use the runners. The runs-on key must match the name of the GCE Instance Template (e.g., gcp-ubuntu-latest or gcp-ubuntu-24-04-8core-arm).
jobs:
test:
runs-on: gcp-ubuntu-latest # Must match GCE Template Name
steps:
- run: echo "Hello from Google Cloud!"By default, Terraform stores state locally. It's highly recommended to migrate this state to a remote Google Cloud Storage (GCS) backend.
Copy providers.tf.gcs to providers.tf (configured for GCS backend):
cp providers.tf.gcs providers.tfRun $HOME/terraform init -migrate-state to copy your local state to the bucket:
$HOME/terraform init -migrate-stateYou can now use the self-hosted GitHub Actions Runners on Google Cloud.