Skip to content

About

github-runner

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

Github self-hosted runner Dockerfile and Kubernetes configuration

awesome-runners

This repository contains a Dockerfile that builds a Docker image suitable for running a [self-hosted GitHub runner].

You can build this image yourself, or use the Docker image from the Docker Hub.

Building the container

docker build -t github-runner .

Examples

Register a runner to a repository.

docker run --name github-runner \
     -e GITHUB_OWNER=username-or-organization \
     -e GITHUB_REPOSITORY=my-repository \
     -e GITHUB_PAT=[PAT] \
     rkdixit03/github-runner

Register a runner with github token.

docker run --name github-runner \
     -e GITHUB_OWNER=username-or-organization \
     -e GITHUB_REPOSITORY=my-repository \
     -e GITHUB_TOKEN=[github.token] \
     rkdixit03/github-runner

Create an organization-wide runner.

docker run --name github-runner \
    -e GITHUB_OWNER=username-or-organization \
    -e GITHUB_PAT=[PAT] \
    rkdixit03/github-runner

Set labels on the runner.

docker run --name github-runner \
    -e GITHUB_OWNER=username-or-organization \
    -e GITHUB_REPOSITORY=my-repository \
    -e GITHUB_PAT=[PAT] \
    -e RUNNER_LABELS=comma,separated,labels \
    rkdixit03/github-runner

Install additional tools on the runner.

docker run --name github-runner \
    -e GITHUB_OWNER=username-or-organization \
    -e GITHUB_REPOSITORY=my-repository \
    -e GITHUB_PAT=[PAT] \
    -e ADDITIONAL_PACKAGES=firefox-esr,chromium \
    rkdixit03/github-runner

secret.yaml

apiVersion: v1
kind: Secret
metadata:
  name: github-secret
stringData:
  GITHUB_PAT: ghp_XXXXXXXXXXXX
kubectl apply -f ./secret.yaml

Kubernetes.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: github-runner
  labels:
    app: github-runner
spec:
  replicas: 2
  selector:
    matchLabels:
      app: github-runner
  template:
    metadata:
      labels:
        app: github-runner
    spec:
      containers:
      - name: github-runner
        image: rkdixit03/github-runner:latest
        env:
        - name: GITHUB_OWNER
          value: rkdixit03
        - name: GITHUB_PAT # stored separately in a Kubernetes secret
          valueFrom:
            secretKeyRef:
              name: github-secret
              key: GITHUB_PAT

Deploy changes in K8s

kubectl apply -f Kubernetes.yaml

Check deployment status

kubectl get deployment

Check number of Pods deployed

kubectl get pods

To test out the things in local, Install Minikube + hyperkit(or Virtual VM) and apply changes there.

Start Minikube

minikube start --vm-driver=hyperkit --alsologtostderr

Now, apply above mentioned changes.

About

github-runner

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages