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.2.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.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nested_runner-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 62613f1a3f26aa88379390f2dc8e1af1d0034f3ff4bcd33e1f5a8471b60cbf55
MD5 5e3146455e112c2f54afa9e18a35eb18
BLAKE2b-256 bf6e2dd66cea715ee3ca3839566677297d53d8199b81e11de8d96b17e7143566

See more details on using hashes here.

Provenance

The following attestation bundles were made for nested_runner-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: nested_runner-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d94e61e3f9ae77483d8476f68ddbb35d4b584bb841929e79f08a394f3c52bb8a
MD5 d5eff77bb0ed54dd0fc561c0c7cc1b8f
BLAKE2b-256 01776ad40a3e70876ee33d38c1087d1ac5d27e8b735b8fb0d079def654985f15

See more details on using hashes here.

Provenance

The following attestation bundles were made for nested_runner-0.1.2-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