Skip to content

Spin up an on-demand self-hosted GitHub action runner with multi-arch supported Ubuntu image.

Notifications You must be signed in to change notification settings

thevickypedia/github-runner-linux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Runner Linux

Test Runner
Build and Publish

Spin up an on-demand self-hosted GitHub action runner with multi-arch supported Ubuntu image.

Usage

Docker Run

docker run thevickypedia/github-runner-linux

Docker Compose

docker compose up -d

Environment Variables

  • GIT_TOKEN - Required for authentication to add runners.
  • GIT_OWNER - GitHub account username [OR] organization name.
  • GIT_REPOSITORY - Repository name (required to create runners dedicated to a particular repo)
  • RUNNER_GROUP - Runner group. Uses default
  • RUNNER_NAME - Runner name. Uses a random instance ID.
  • WORK_DIR - Work directory. Uses _work
  • LABELS - Runner labels (comma separated). Uses "docker-node,${os_name}-${architecture}"
  • REUSE_EXISTING - Re-use existing configuration. Defaults to false

Note

REUSE_EXISTING flag can be useful when a container restarts due to an issue or when a container is reused after being terminated without shutting down gracefully.

More info

Following files/directories are created (commonly across macOS, Linux and Windows runners) only when the runner has been configured

  • _work
  • _diag
  • .runner
  • .credentials
  • .credentials_rsaparams

So, a simple check on one or more of these files' presence should confirm if the runner has been configured already

Note: Warnings like the ones below are common, and GitHub typically reconnects the runner automatically.

A session for this runner already exists.
Runner connect error: The actions runner i-058175xh7908r2u46 already has an active session.. Retrying until reconnected.

Warning

Using this image without the env var GIT_REPOSITORY will create an organization level runner.
Using self-hosted runners in public repositories pose some considerable security threats.

Env vars for notifications

This project supports ntfy and telegram bot for startup/shutdown notifications.

NTFY

Choose ntfy setup instructions with basic OR authentication abilities

  • NTFY_URL - Ntfy endpoint for notifications.
  • NTFY_TOPIC - Topic to which the notifications have to be sent.
  • NTFY_USERNAME - Ntfy username for authentication (if topic is protected)
  • NTFY_PASSWORD - Ntfy password for authentication (if topic is protected)

Telegram

Steps for telegram bot configuration

  1. Use BotFather to create a telegram bot token
  2. Send a test message to the Telegram bot you created
  3. Use the URL https://api.telegram.org/bot{token}/getUpdates to get the Chat ID
    • You can also use Thread ID to send notifications to a particular thread within a group
export TELEGRAM_BOT_TOKEN="your-bot-token"
export CHAT_ID=$(curl -s "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getUpdates" | jq -r '.result[0].message.chat.id')
  • TELEGRAM_BOT_TOKEN - Telegram Bot token
  • TELEGRAM_CHAT_ID - Chat ID to which the notifications have to be sent.
  • THREAD_ID - Optional thread ID to send notifications to a specific thread.

Note: To send notifications to threads, the bot should be added to a group with Topics enabled.
Send a message to the bot in a group thread

export THREAD_ID=$(curl -s "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getUpdates" | jq -r '.result[0]|.update_id')

Development

Set latest RUNNER_VERSION

RUNNER_VERSION=$(curl -sL \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/actions/runner/releases/latest | jq .tag_name --raw-output)

export RUNNER_VERSION="${RUNNER_VERSION#?}"

Build

docker build --build-arg RUNNER_VERSION=$RUNNER_VERSION -t runner .

About

Spin up an on-demand self-hosted GitHub action runner with multi-arch supported Ubuntu image.

Resources

Stars

Watchers

Forks

Packages

No packages published