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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nested_runner-0.2.0.tar.gz.
File metadata
- Download URL: nested_runner-0.2.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31e36247a57b21ce89cda88fc9dd456bb50247d0a4b36bb28f14ed6f8500283d
|
|
| MD5 |
056cb47456644084d4ed5a84160fdb70
|
|
| BLAKE2b-256 |
f6d125e8ae26b936faedff32056c3035977026442efca4b6204611fcaf84a9a2
|
Provenance
The following attestation bundles were made for nested_runner-0.2.0.tar.gz:
Publisher:
cd.yml on wprhvso/nested-runner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nested_runner-0.2.0.tar.gz -
Subject digest:
31e36247a57b21ce89cda88fc9dd456bb50247d0a4b36bb28f14ed6f8500283d - Sigstore transparency entry: 2395205567
- Sigstore integration time:
-
Permalink:
wprhvso/nested-runner@1f7ca3f612d9a886b0e564d838e5e342df65ef8c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/wprhvso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@1f7ca3f612d9a886b0e564d838e5e342df65ef8c -
Trigger Event:
push
-
Statement type:
File details
Details for the file nested_runner-0.2.0-py3-none-any.whl.
File metadata
- Download URL: nested_runner-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f24239e2137e5c52b6e806e0a11334c9a7c41695d6b567102c85aeedc167bdaf
|
|
| MD5 |
11d309982a782dcf1a67b7669106317d
|
|
| BLAKE2b-256 |
2c9ca95823812cdc8b13f10d4135ea6c63242ec609b66fc44ecb6628181518cf
|
Provenance
The following attestation bundles were made for nested_runner-0.2.0-py3-none-any.whl:
Publisher:
cd.yml on wprhvso/nested-runner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nested_runner-0.2.0-py3-none-any.whl -
Subject digest:
f24239e2137e5c52b6e806e0a11334c9a7c41695d6b567102c85aeedc167bdaf - Sigstore transparency entry: 2395205623
- Sigstore integration time:
-
Permalink:
wprhvso/nested-runner@1f7ca3f612d9a886b0e564d838e5e342df65ef8c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/wprhvso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@1f7ca3f612d9a886b0e564d838e5e342df65ef8c -
Trigger Event:
push
-
Statement type: