From ac0dbf4df478db3658929b07fd08516a73cc1ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeffry=20W=C3=BCrmli?= Date: Mon, 23 Nov 2026 05:04:01 +0100 Subject: [PATCH 1/3] ci: run lint-test (Linux) and secret scan on the self-hosted runner Fork PRs and the macOS leg stay on GitHub-hosted runners, as does the bootstrap job, which needs a pristine Ubuntu machine. The gitleaks step copies the checkout into the scan container instead of bind-mounting it, because the runner is itself a container and $PWD is not a host path. Refs DOTFI-24 --- .github/workflows/ci.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bd7a89..5769fa8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - runs-on: ${{ matrix.os }} + # The Linux leg runs on the self-hosted runner; the matrix value stays + # "ubuntu-latest" so the required check names do not change. Fork PRs never + # reach the self-hosted runner (it has the host Docker socket). + runs-on: ${{ matrix.os == 'macos-latest' && 'macos-latest' || (github.event.pull_request.head.repo.fork != true && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest') }} timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -29,8 +32,11 @@ jobs: - name: Install zsh + shellcheck run: | if [ "$RUNNER_OS" = Linux ]; then - sudo apt-get update -qq - sudo apt-get install -y -qq zsh shellcheck + # The self-hosted runner image runs as root and ships no sudo. + SUDO="" + [ "$(id -u)" -eq 0 ] || SUDO="sudo" + $SUDO apt-get update -qq + $SUDO apt-get install -y -qq zsh shellcheck else brew install shellcheck fi @@ -80,15 +86,23 @@ jobs: secrets: name: secret scan (full history) - runs-on: ubuntu-latest + # Self-hosted runner for same-repo runs only; fork PRs stay on GitHub's runners. + runs-on: ${{ github.event.pull_request.head.repo.fork != true && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest' }} timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false + # `docker run -v "$PWD:/repo"` resolves $PWD on the Docker host, which is + # not the runner's path when the runner itself is a container. Copy the + # checkout into the scan container instead; this works on both runner kinds. - name: gitleaks run: | - docker run --rm -v "$PWD:/repo" \ + cid="$(docker create \ zricethezav/gitleaks@sha256:c00b6bd0aeb3071cbcb79009cb16a60dd9e0a7c60e2be9ab65d25e6bc8abbb7f \ - git /repo --no-banner --redact -v + git /repo --no-banner --redact -v)" + trap 'docker rm -f "$cid" >/dev/null' EXIT + docker cp "$PWD/." "$cid:/repo" + docker start -a "$cid" || true + exit "$(docker inspect -f '{{.State.ExitCode}}' "$cid")" From 10f16142df3727d720ceb883da7c0a84268d4cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeffry=20W=C3=BCrmli?= Date: Mon, 23 Nov 2026 05:05:27 +0100 Subject: [PATCH 2/3] ci: gate the self-hosted runner on a positive trust check Select the self-hosted runner only for non-PR events and for same-repo, non-Dependabot pull requests, so a missing head repo or any cross-repo PR falls back to GitHub-hosted runners. Let the gitleaks step return the scan container's exit code directly instead of masking it. Refs DOTFI-24 --- .github/workflows/ci.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5769fa8..a338cc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,9 @@ jobs: os: [ubuntu-latest, macos-latest] # The Linux leg runs on the self-hosted runner; the matrix value stays # "ubuntu-latest" so the required check names do not change. Fork PRs never - # reach the self-hosted runner (it has the host Docker socket). - runs-on: ${{ matrix.os == 'macos-latest' && 'macos-latest' || (github.event.pull_request.head.repo.fork != true && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest') }} + # reach the self-hosted runner (it has the host Docker socket); neither do + # Dependabot PRs, whose workflow changes are unreviewed until merged. + runs-on: ${{ matrix.os == 'macos-latest' && 'macos-latest' || ((github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest') }} timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -86,8 +87,9 @@ jobs: secrets: name: secret scan (full history) - # Self-hosted runner for same-repo runs only; fork PRs stay on GitHub's runners. - runs-on: ${{ github.event.pull_request.head.repo.fork != true && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest' }} + # Self-hosted runner for trusted runs only (see lint-test); other PRs stay on + # GitHub's runners. + runs-on: ${{ (github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest' }} timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -104,5 +106,4 @@ jobs: git /repo --no-banner --redact -v)" trap 'docker rm -f "$cid" >/dev/null' EXIT docker cp "$PWD/." "$cid:/repo" - docker start -a "$cid" || true - exit "$(docker inspect -f '{{.State.ExitCode}}' "$cid")" + docker start -a "$cid" From 754b9c5a5aa4cd00c8d2bcaab2dbcd6a62fe5a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeffry=20W=C3=BCrmli?= Date: Mon, 23 Nov 2026 05:06:28 +0100 Subject: [PATCH 3/3] ci: identify Dependabot PRs by author and branch, not by actor github.actor is whoever triggered the run, so a maintainer re-running a Dependabot PR would have moved it onto the self-hosted runner. Use the PR author and the head branch prefix instead. Refs DOTFI-24 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a338cc4..c32da18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: # "ubuntu-latest" so the required check names do not change. Fork PRs never # reach the self-hosted runner (it has the host Docker socket); neither do # Dependabot PRs, whose workflow changes are unreviewed until merged. - runs-on: ${{ matrix.os == 'macos-latest' && 'macos-latest' || ((github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest') }} + runs-on: ${{ matrix.os == 'macos-latest' && 'macos-latest' || ((github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'dependabot[bot]' && !startsWith(github.event.pull_request.head.ref, 'dependabot/'))) && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest') }} timeout-minutes: 10 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -89,7 +89,7 @@ jobs: name: secret scan (full history) # Self-hosted runner for trusted runs only (see lint-test); other PRs stay on # GitHub's runners. - runs-on: ${{ (github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')) && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest' }} + runs-on: ${{ (github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'dependabot[bot]' && !startsWith(github.event.pull_request.head.ref, 'dependabot/'))) && fromJSON('["self-hosted","Linux","X64","docker"]') || 'ubuntu-latest' }} timeout-minutes: 5 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1