Skip to content

Instantly share code, notes, and snippets.

@pmanlukas
Last active July 6, 2020 12:55
Show Gist options
  • Save pmanlukas/8bfd04814c0457620aef9b537442cf1b to your computer and use it in GitHub Desktop.
Save pmanlukas/8bfd04814c0457620aef9b537442cf1b to your computer and use it in GitHub Desktop.
These scripts allow one to setup a GCP VM (based on the default debian image) to act as a self-hosted runner and to config the runner as a service. You will need a working GCP project and service account associated with it as well as a configured GCP CLI.
gcloud compute ssh ghe-runner-gcp --command="gsutil cp gs://gh-runner/delete-service.sh . && chmod +x delete-service.sh && ./delete-service.sh <owner> <repo> <token>"
gcloud compute instances delete ghe-runner-gcp --quiet
#!/bin/sh
GITHUB_OWNER=$1
GITHUB_REPOSITORY=$2
GITHUB_PAT=$3
export RUNNER_CFG_PAT=${GITHUB_PAT}
curl -s https://raw.githubusercontent.com/actions/runner/automate/scripts/remove-svc.sh | bash -s ${GITHUB_OWNER}/${GITHUB_REPOSITORY}
# setup vm
gcloud compute instances create ghe-runner-gcp \
--zone=europe-west3-c --machine-type=n1-standard-1 \
--subnet=default --network-tier=PREMIUM \
--service-account=<gcp-service-account> \
--scopes=https://www.googleapis.com/auth/cloud-platform --tags=https-server \
--image=debian-9-stretch-v20200420 --image-project=debian-cloud \
--boot-disk-size=10GB --boot-disk-type=pd-standard \
--boot-disk-device-name=ghe-runner-gcp
# setup runner
gcloud compute ssh ghe-runner-gcp --command="gsutil cp gs://gh-runner/setup-service.sh . && chmod +x setup-service.sh && ./setup-service.sh <owner> <repo> <token>"
#!/bin/sh
GITHUB_OWNER=$1
GITHUB_REPOSITORY=$2
GITHUB_PAT=$3
# setup enviroment
sudo apt-get update
sudo apt-get install -y git-core curl build-essential openssl libssl-dev python
sudo apt-get install -y liblttng-ust0 libkrb5-3 zlib1g
sudo apt install -y libssl1.1$ || apt install -y libssl1.0.2$ || apt install -y libssl1.0.0$
sudo apt install -y libicu57
sudo apt-get install -y jq
# install nodejs
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
# setup docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ${USER}
sudo chmod 666 /var/run/docker.sock
export RUNNER_CFG_PAT=${GITHUB_PAT}
curl -s https://raw.githubusercontent.com/actions/runner/automate/scripts/create-latest-svc.sh | bash -s ${GITHUB_OWNER}/${GITHUB_REPOSITORY}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment