Skip to content

JulienBreux/cloud-run-github-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎽 Cloud Run Github runner

Getting started

Deploy to Cloud Run worker pool

Clone:

git clone https://github.com/JulienBreux/cloud-run-github-runner/

Create the secret:

Important

Change the values of GITHUB_SECRET_VALUE. See How to get a Github register token

gcloud secrets create GH_TOKEN --replication-policy="automatic"
echo -n "GITHUB_SECRET_VALUE" | gcloud secrets versions add GH_TOKEN --data-file=-

Permissions:

Note

Need to set the secretAccessor to the right service account.

gcloud secrets add-iam-policy-binding GH_TOKEN \
--member="serviceAccount:[email protected]" \
--role="roles/secretmanager.secretAccessor"

Deploy:

Important

Change the values of GITHUB_USER_OR_ORGANIZATION and REPOSITORY_NAME.

gcloud alpha run worker-pools deploy cloud-run-github-runner \
--source=. \
--min=1 \
--set-env-vars GH_OWNER=GITHUB_USER_OR_ORGANIZATION,GH_REPOSITORY=REPOSITORY_NAME \
--set-secrets GH_TOKEN=GH_TOKEN:latest

Note

In this case cloud-run-github-runner is the name of the Cloud Run Worker pool.

Deploy to Docker

Clone:

git clone https://github.com/JulienBreux/cloud-run-github-runner/

Build:

cd cloud-run-github-runner/
docker build \
--build-arg TARGETOS=linux \
--build-arg TARGETARCH=amd64 \
--build-arg RUNNER_VERSION=2.292.0 \
--tag cloud-run-github-runner .

Deploy:

Important

Change the values of GITHUB_TOKEN, GITHUB_USER_OR_ORGANIZATION and REPOSITORY_NAME.

docker run \
-e GH_TOKEN=GITHUB_TOKEN \
-e GH_OWNER=GITHUB_USER_OR_ORGANIZATION \
-e GH_REPOSITORY=REPOSITORY_NAME \
-d cloud-run-github-runner

Note

In this case cloud-run-github-runner is the name of the Cloud Run Worker pool.

How to get a Github register token

Very simple, go to "Add new self-hosted runner" in settings section of your repository. For example: https://github.com/JulienBreux/cloud-run-github-runner/settings/actions/runners/new

example of hosted runner form

Copy the register token.

Security

See CONTRIBUTING for more information.

License

Apache 2.0