Skip to main content

nested-runner

Self-hosted раннеры GitHub Actions, которые сами крутятся внутри GitHub Actions (ubuntu-latest). Матрёшка.

Зачем: доказать, что так можно. Кто потащит в прод — тот лох.

Как это работает

Заводит в целевом репо эфемерный runner scale set и слушает его очередь. Пришёл job — контроллер забирает его и диспатчит runner.yml у себя. Тот поднимает внутри ubuntu-latest, регистрирует его в scale set целевого репо по JIT-конфигу, отрабатывает один job и умирает. Больше NESTED_MAX раннеров одновременно не бывает. docker compose down сносит scale set, раннеров и висящие запуски.

Что нажать

1. Создать токен

Аккаунт должен быть админом целевого репозитория и коллабаратором этого.

Settings → Developer settings → Personal access tokens → Tokens (classic) → Generate new token (classic).

Имя nested, no expiration, скоупы repo и workflow.

2. Положить compose-файл

mkdir -p /opt/nested-runner && nano /opt/nested-runner/compose.yml:

services:
  nested-runner:
    image: ghcr.io/wprhvso/nested-runner:latest
    container_name: nested-runner
    restart: unless-stopped
    stop_grace_period: 2m
    command: ["owner/target"]
    environment:
      GH_TOKEN: ${GH_TOKEN:?нужен токен в .env}
      # GH_REPO: wprhvso/nested-runner
      # NESTED_SCALE_SET: nested
      # NESTED_MAX: 20
      # NESTED_WORKFLOW: runner.yml
      # NESTED_DEBUG: 1

Токен — рядом, в /opt/nested-runner/.env:

GH_TOKEN=ghp_...
chmod 600 /opt/nested-runner/.env

Целевых репозиториев можно перечислить сразу несколько: command: ["owner/a", "owner/b"].

3. Запустить

env -C /opt/nested-runner docker compose up -d

Логи:

env -C /opt/nested-runner docker compose logs -f

Снести:

env -C /opt/nested-runner docker compose down

4. Поправить runs-on во всех нужных workflow

runs-on: nested

Использовать массивы в runs-on нельзя.

5. Проверить запуском своего workflow

Обновление

env -C /opt/nested-runner docker compose pull && env -C /opt/nested-runner docker compose up -d

Команды

Команда Что делает
just build собрать образ локально
just run <repo> собрать и запустить, переменные подставит сам
just version [vX.Y.Z] показать или проставить версию
just tag тег vX.Y.Z и пуш
just test тестовый workflow
just qa yamllint, actionlint, ruff, basedpyright
just keys сгенерировать пару ключей, уже сделано

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nested_runner-0.1.3.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nested_runner-0.1.3-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file nested_runner-0.1.3.tar.gz.

File metadata

  • Download URL: nested_runner-0.1.3.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nested_runner-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a6f9729f2414ee4d844f6c4234c00e886c7b06365554d74ff3c9cbda3ed3721c
MD5 40d879c8bb69827f640e5ff33bb7c053
BLAKE2b-256 1250d2ad96da3213a77f6ce5203e969c154afaa7bbdfe0eebf21c4108d24e990

See more details on using hashes here.

Provenance

The following attestation bundles were made for nested_runner-0.1.3.tar.gz:

Publisher: cd.yml on wprhvso/nested-runner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nested_runner-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: nested_runner-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nested_runner-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 54dca278261b6ea261fb4f96fb9844fd123ae73a37c4302e8ae783d76592b260
MD5 a480e0e7a7c3fc34aee2f3f4166619d9
BLAKE2b-256 e977699eebdded2fcf8602d3b98aa6df0143b74df628540f076212ae766b71ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for nested_runner-0.1.3-py3-none-any.whl:

Publisher: cd.yml on wprhvso/nested-runner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page