承接 jonpugh/github-runner 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jonpugh/github-runner

Composer 安装命令:

composer require jonpugh/github-runner

包简介

A shell script for installing, configuring, and launching github runners in a single process.

README 文档

README

image

A single Bash script to install, configure, optionally launch, and clean up GitHub self-hosted runners. It automates:

  • Downloading the proper Actions Runner build for your OS/arch
  • Getting a registration token via the GitHub API
  • Configuring the runner with your repository, name, and labels
  • Optionally launching run.sh and handling cleanup on exit

This project also includes a minimal Docker setup for local testing and examples.

Features

  • One-command setup for a self-hosted runner
  • Works with environment variables or CLI flags (or a .env file)
  • Automatically detects architecture (x64/arm64) and latest runner release
  • Graceful stop/cancel handlers that can remove the runner and unregister it
  • Optional Docker compose example for running/scaling multiple runners

Requirements

  • Bash, curl, tar
  • jq (used to parse GitHub API responses)
  • Network access to GitHub
  • A GitHub Personal Access Token (classic) or PAT with appropriate scopes: needs repo access and "self-hosted runners" administration for the target repository. Practically, you’ll want a token that can create registration tokens on the repository (often described here as admin:write on the repo in this script’s messages).

Installation

You can use the script directly, or install it via Composer so github-runner-starter is available on your PATH.

Option A: Use the script directly

  • Clone or download this repository.
  • From the project root, run:
    • ./github-runner-starter --help

Option B: Composer

If Composer is available in your environment:

  • Add as a dependency or install globally. The package exposes a bin named github-runner-starter.

composer.json excerpt:

"bin": [
  "github-runner-starter"
]

Quick start

  1. Ensure you have a suitable PAT and know the owner/repo you want to register the runner to.
  2. In a working directory, create a .env file or pass flags (see below).
  3. Run the script.

Example with flags, including launching the runner immediately:

export GITHUB_REPOSITORY=operations-project/github-runner-starter
export GITHUB_TOKEN=ghp_***
./github-runner-starter \
  --labels=my-runner,linux \
  --run

If you omit --run, the script will download and configure the runner, but not launch run.sh. You can start it later manually from the runner directory.

CLI options and environment variables

All options can be provided either as CLI flags or via environment variables. A .env file in the current working directory will be sourced automatically.

  • --runner-path (env: RUNNER_PATH)
    • The path where the runner files will be downloaded/extracted (default: runner).
  • --cleanup-runner (env: RUNNER_CLEANUP)
    • When canceling with Ctrl+C, remove the downloaded runner directory. Set value to yes to enable.
  • --token (env: GITHUB_TOKEN)
    • GitHub API token used to obtain the registration token for the runner. Required when configuring.
  • --repo (env: GITHUB_REPOSITORY)
    • Target repository, e.g., owner/repo. Required when configuring.
  • --name (env: RUNNER_CONFIG_NAME)
    • Runner name. Defaults to $(whoami)@$(hostname -f).
  • --labels (env: RUNNER_CONFIG_LABELS)
    • Comma-separated labels. Defaults to $(whoami)@$(hostname -f) and the runner name is also appended.
  • --run (env: RUNNER_RUN)
    • If set, the script will launch run.sh after configuration completes.
  • --config-sh-options (env: RUNNER_CONFIG_OPTIONS)
    • Extra options to append to the runner’s config.sh command.
  • --no-config (env: RUNNER_CONFIG)
    • Skip the config.sh step. Useful if you only want to download/extract the runner.
  • --help
    • Show inline help.

See .env.example for a full set of variables and inline documentation.

How it works

At a high level the script does the following:

  1. Verify inputs, source .env if present, and compute defaults.
  2. Request a short-lived registration token from the GitHub API for the given repository.
  3. Determine the latest runner version and your architecture.
  4. Download the appropriate runner tarball if not already present and extract it.
  5. Run the runner’s config.sh with your parameters and labels.
  6. Optionally start run.sh and wait on it.

On SIGTERM (stop) the script attempts to stop the runner and unregister it using config.sh remove with the same registration token. On SIGINT (Ctrl+C/cancel) it can optionally delete the runner directory if RUNNER_CLEANUP=yes is set.

Examples

  • Configure only (no immediate run):
./github-runner-starter
  • Configure and run:
./github-runner-starter --run
  • Custom path and labels:
./github-runner-starter \
  --runner-path=/opt/gh-runner \
  --labels=linux,x64
  • Pass extra options to config.sh:
./github-runner-starter \
  --config-sh-options="--ephemeral"

Docker usage (optional)

This repository includes a Dockerfile and docker-compose.yml for testing/development.

  • Build and run with docker compose:
docker compose up --build

The compose file passes through GITHUB_TOKEN and targets this repo by default. You can override env vars via your shell or a .env file.

  • Scaling multiple runners: The whichami helper in this repo, used by docker-entrypoint, creates a unique suffix for the runner name when scaling services:
docker compose up --build --scale runner=3

Each container will get a distinct RUNNER_CONFIG_NAME like runner1@hostname, runner2@hostname, etc.

Note: The provided Docker image is for development. It installs dependencies and runs as the runner user in /github-runner-starter.

Troubleshooting

  • "GITHUB_REPOSITORY is required": Provide --repo=owner/repo or set GITHUB_REPOSITORY.
  • "GITHUB_TOKEN is required": Provide --token=... or set GITHUB_TOKEN. Ensure it has sufficient permissions to create a registration token for the repo.
  • "Unable to get registration token": Often indicates insufficient token scope, wrong repo, or network issues. The script will echo the API response for details.
  • "Unable to determine CLI version": Ensure your token can access the actions/runner releases API endpoint and network egress is available.
  • Architecture errors: The script detects uname -m as x86_64 (x64) or arm64. Other architectures are not handled.

Security considerations

  • Treat GITHUB_TOKEN as sensitive. Avoid committing it to source control or baking it into images.
  • When using Docker, prefer passing the token via environment at runtime, not building it into the image.

Notes

I wrote the shell script. JetBrains Junie AI wrote the README from that.

License

MIT License. See LICENSE for details.

Author

  • Jon Pugh (@jonpugh)
  • Junie AI in PHPStorm.

jonpugh/github-runner 适用场景与选型建议

jonpugh/github-runner 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 1.57k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jonpugh/github-runner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jonpugh/github-runner 我们能提供哪些服务?
定制开发 / 二次开发

基于 jonpugh/github-runner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: Shell

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-13