function github-runner {
org=$(dirname $1)
repo=$(basename $1)
token=$2
index=$3
tag=${4:-latest}
runner_group=${5:-Default}
name=github-runner-${org}-${repo}-${index}
docker rm -f $name
docker run -d --restart=always \
-e REPO_URL="https://github.com/${org}/${repo}" \
-e RUNNER_TOKEN="$token" \
-e RUNNER_NAME="linux-${repo}-${index}" \
-e RUNNER_WORKDIR="/tmp/github-runner-${repo}-${index}" \
-e RUNNER_GROUP="$runner_group" \
-e LABELS="the-runner" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/github-runner-${repo}-${index}:/tmp/github-runner-${repo}-${index} \
--name $name myoung34/github-runner:$tag
}
For example, you can run following command:
github-runner e10101/learn-rust ARGHANOTHERGITHUBACTIONSTOKEN 1
github-runner e10101/learn-rust ARGHANOTHERGITHUBACTIONSTOKEN 2 ubuntu-focal
github-runner your-account/some-other-repo ARGHANOTHERGITHUBACTIONSTOKEN ubuntu-focal
function github-runner-org {
org=$1
token=$2
index=$3
labels=$4
tag=${5:-latest}
runner_group=${6:-Default}
name=github-runner-${org}-${index}
docker rm -f $name
docker run -d --restart=always \
-e ORG_NAME="$org" \
-e RUNNER_SCOPE="org" \
-e RUNNER_TOKEN="$token" \
-e RUNNER_NAME="${org}-runner-${index}" \
-e RUNNER_WORKDIR="/tmp/github-runner-${org}-${index}" \
-e RUNNER_GROUP="$runner_group" \
-e LABELS="$labels" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/github-runner-${org}-${index}:/tmp/github-runner-${org}-${index} \
--name $name myoung34/github-runner:$tag
}
# Using default runner group "Default" and latest tag
github-runner-org your-org-name YOUR_ORG_RUNNER_TOKEN 1 "org-runner,linux"
# Specifying a custom runner group and tag
github-runner-org your-org-name YOUR_ORG_RUNNER_TOKEN 2 "org-runner,docker" ubuntu-focal "Custom Group"
# Using default runner group with specific labels and tag
github-runner-org your-org-name YOUR_ORG_RUNNER_TOKEN 3 "org-runner,aws,python" ubuntu-focal
# Specifying labels, tag, and runner group
github-runner-org your-org-name YOUR_ORG_RUNNER_TOKEN 4 "org-runner,gpu" ubuntu-focal "Another Group"
# Example
export $TOKEN=********
github-runner-org tinylink-project $TOKEN 1 "linter" ubuntu-focal "lint"