Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dockerised GitHub Actions self-hosted runner using ubuntu and rootless-dind

License

NotificationsYou must be signed in to change notification settings

msyea/github-actions-runner-rootless

Built onubuntu:20.04, configured for rootless dind 🎉, impossible without invaluable advice from@kenichi-shibata and@sidick.

Inspiration from

Images

Docker Github Actions Runner

Docker Pulls

This will run thenew self-hosted github actions runners.

Environment Variables

Environment VariableDescription
RUNNER_NAMEThe name of the runner to use. Supercedes (overrides)RUNNER_NAME_PREFIX
RUNNER_NAME_PREFIXA prefix for a randomly generated name (followed by a random 13 digit string). You must not also provideRUNNER_NAME. Defaults togithub-runner
ACCESS_TOKENAgithub PAT to use to generateRUNNER_TOKEN dynamically at container start. Not using this requires a validRUNNER_TOKEN
ORG_RUNNEROnly valid if usingACCESS_TOKEN. This will set the runner to an org runner. Default is 'false'. Valid values are 'true' or 'false'. If this is set to true you must also setORG_NAME and makesREPO_URL unneccesary
ORG_NAMEThe organization name for the runner to register under. RequiresORG_RUNNER to be 'true'. No default value.
LABELSA comma separated string to indicate the labels. Default is 'default'
REPO_URLIf using a non-organization runner this is the full repository url to register under such as 'https://github.com/msyea/repo'
RUNNER_TOKENIf not using a PAT forACCESS_TOKEN this will be the runner token provided by the Add Runner UI (a manual process). Note: This token is short lived and will change frequently.ACCESS_TOKEN is likely preferred.
RUNNER_WORKDIRThe working directory for the runner. Runners on the same host should not share this directory. Default is '/_work'. This must match the source path for the bind-mounted volume at RUNNER_WORKDIR, in order for container actions to access files.
RUNNER_GROUPName of the runner group to add this runner to (defaults to the default runner group)
GITHUB_HOSTOptional URL of the Github Enterprise server e.g github.mycompany.com. Defaults togithub.com.

Manual

# org runnerdocker run -d --restart always --name github-runner \  -e RUNNER_NAME_PREFIX="myrunner" \  -e ACCESS_TOKEN="footoken" \  -e RUNNER_WORKDIR="/tmp/github-runner-your-repo" \  -e RUNNER_GROUP="my-group" \  -e ORG_RUNNER="true" \  -e ORG_NAME="octokode" \  -e LABELS="my-label,other-label" \  msyea/github-actions-runner:latest# per repodocker run -d --restart always --name github-runner \  -e REPO_URL="https://github.com/msyea/repo" \  -e RUNNER_NAME="foo-runner" \  -e RUNNER_TOKEN="footoken" \  -e RUNNER_WORKDIR="/tmp/github-runner-your-repo" \  -e RUNNER_GROUP="my-group" \  msyea/github-actions-runner:latest

Or shell wrapper:

functiongithub-runner {    name=github-runner-${1//\//-}    org=$(dirname$1)    repo=$(basename$1)    tag=${3:-latest}    docker rm -f$name    docker run -d --restart=always \        -e REPO_URL="https://github.com/${org}/${repo}" \        -e RUNNER_TOKEN="$2" \        -e RUNNER_NAME="linux-${repo}" \        -e RUNNER_WORKDIR="/tmp/github-runner-${repo}" \        -e RUNNER_GROUP="my-group" \        -e LABELS="my-label,other-label" \        --name$name${org}/github-runner:${tag}}github-runner your-account/your-repo       AARGHTHISISYOURGHACTIONSTOKENgithub-runner your-account/some-other-repo ARGHANOTHERGITHUBACTIONSTOKEN ubuntu-xenial

Ordocker-compose.yml:

version:'2.3'services:worker:image:msyea/github-actions-runner:latestenvironment:REPO_URL:https://github.com/example/repoRUNNER_NAME:example-nameRUNNER_TOKEN:someGithubTokenHereRUNNER_GROUP:my-groupORG_RUNNER:'false'LABELS:linux,x64,gpu

Usage From GH Actions Workflow

name:Packageon:release:types:[created]jobs:build:runs-on:self-hostedsteps:    -uses:actions/checkout@v1    -name:build packagesrun:make all

Automatically Acquiring a Runner Token

A runner token can be automatically acquired at runtime ifACCESS_TOKEN (a GitHub personal access token) is a supplied. This uses theGitHub Actions API. e.g.:

docker run -d --restart always --name github-runner \  -e ACCESS_TOKEN="footoken" \  -e RUNNER_NAME="foo-runner" \  -e RUNNER_WORKDIR="/tmp/github-runner-your-repo" \  -e RUNNER_GROUP="my-group" \  -e ORG_RUNNER="true" \  -e ORG_NAME="octokode" \  -e LABELS="my-label,other-label" \  msyea/github-actions-runner:latest

Create GitHub personal access token

Creating GitHub personal access token (PAT) for using by self-hosted runner make sure the following scopes are selected:

  • repo (all)
  • admin:org (all)(mandatory for organization-wide runner)
  • admin:public_key - read:public_key
  • admin:repo_hook - read:repo_hook
  • admin:org_hook
  • notifications
  • workflow

Also, when creating a PAT for self-hosted runner which will process events from several repositories of the particular organization, create the PAT using organization owner account. Otherwise your new PAT will not have sufficient privileges for all repositories.

About

Dockerised GitHub Actions self-hosted runner using ubuntu and rootless-dind

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

    Packages

     
     
     

    Contributors3

    •  
    •  
    •  

    [8]ページ先頭

    ©2009-2025 Movatter.jp