diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5c8e2b..2b49759 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -154,7 +154,7 @@ jobs: - name: use-php picks each version run: | for v in 8.3 8.4 8.5; do - docker run --rm --entrypoint bash runner-php-smoke:ci -c "id -un | grep -qx runner && RUNNER_TEMP=/tmp use-php $v | grep -q 'PHP $v\.' && composer --version >/dev/null" + docker run --rm --entrypoint bash runner-php-smoke:ci -c "id -un | grep -qx runner && RUNNER_TEMP=/tmp use-php $v | grep -q 'PHP $v\.' && composer --version >/dev/null && gh --version >/dev/null" done # Builds the pg target for the default major and for another major with an extension, and runs diff --git a/CHANGELOG.md b/CHANGELOG.md index fd11f6a..3f0ef36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ the major version is 0, a minor release may change configuration (each such chan ## [Unreleased] +### Added +- The GitHub CLI (`gh` 2.102.0, pinned by version and sha256) in every image variant, so a job can open or comment on issues without a GitHub-hosted runner. Nothing is logged in: a job passes `GH_TOKEN`. + ### Fixed - Jobs queued in a run that GitHub reports as `pending` (for example while it waits on a concurrency group) are served; the controller listed only `queued` and `in_progress` runs and left such jobs waiting forever. diff --git a/README.md b/README.md index 3488042..f36c1d7 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ limits. [docs/deploy.md](docs/deploy.md) has the full guide, rollout and rollbac | Image | Contents | | --- | --- | -| `ghcr.io/farzai/github-runner-railway:` | the official `actions-runner` (Ubuntu 24.04) plus git, curl, jq, python3, build-essential, shellcheck; no `sudo`, no Docker | +| `ghcr.io/farzai/github-runner-railway:` | the official `actions-runner` (Ubuntu 24.04) plus git, curl, jq, python3, build-essential, shellcheck, gh; no `sudo`, no Docker | | `ghcr.io/farzai/github-runner-railway:pg-` | the above plus PostgreSQL 18, Playwright's Chromium/WebKit system libraries and browsers (see `image/Dockerfile` for the pinned versions), and `ci-postgres` | | `ghcr.io/farzai/github-runner-railway:sudo-` | the base image plus passwordless `sudo` for the runner user (opt-in, see below) | | `ghcr.io/farzai/github-runner-railway:php-` | the base image plus PHP 8.3, 8.4 and 8.5 (ondrej/php PPA) and Composer, and `use-php ` to pick one; for PHP projects, since `setup-php` cannot run without sudo | diff --git a/image/Dockerfile b/image/Dockerfile index 90faeac..8512373 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -23,6 +23,19 @@ RUN curl -fsSL -o /tmp/shellcheck.tar.xz \ && install -m 0755 "/tmp/shellcheck-v${SHELLCHECK_VERSION}/shellcheck" /usr/local/bin/shellcheck \ && rm -rf /tmp/shellcheck.tar.xz "/tmp/shellcheck-v${SHELLCHECK_VERSION}" +# The GitHub CLI, so scripts that open or comment on issues (gh issue create, gh api) run on the pool +# instead of needing a GitHub-hosted runner. Pinned release, verified against the sha256 in the +# release's checksums file (the image is built for linux/amd64). No token is baked in: a job passes +# GH_TOKEN itself. +ARG GH_VERSION=2.102.0 +ARG GH_SHA256=bb766f710eef8ede859c18578c72c327597cd4c8a85b06001b1f3843c6019386 +RUN curl -fsSL -o /tmp/gh.tar.gz \ + "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz" \ + && echo "${GH_SHA256} /tmp/gh.tar.gz" | sha256sum -c - \ + && tar -xzf /tmp/gh.tar.gz -C /tmp \ + && install -m 0755 "/tmp/gh_${GH_VERSION}_linux_amd64/bin/gh" /usr/local/bin/gh \ + && rm -rf /tmp/gh.tar.gz "/tmp/gh_${GH_VERSION}_linux_amd64" + # A job must not be able to become root or write the runner's own files as root. RUN (deluser runner sudo || true) \ && (deluser runner docker || true) \ @@ -32,7 +45,7 @@ RUN (deluser runner sudo || true) \ # The build fails here, not at the first job, if any of that did not take. RUN ! id -nG runner | tr ' ' '\n' | grep -qxE 'sudo|docker|root' \ && ! grep -rqs NOPASSWD /etc/sudoers /etc/sudoers.d \ - && for t in git curl jq unzip python3 gcc make shellcheck; do command -v "$t" >/dev/null || { echo "missing $t" >&2; exit 1; }; done + && for t in git curl jq unzip python3 gcc make shellcheck gh; do command -v "$t" >/dev/null || { echo "missing $t" >&2; exit 1; }; done COPY entrypoint.sh /entrypoint.sh RUN chmod 0755 /entrypoint.sh