Skip to content

ci(release): push release tags and changelog as the CI bot GitHub App - #391

Merged
jdfalk merged 3 commits into
mainfrom
ci/bot-app-auth
Nov 7, 2026
Merged

jdfalk merged 3 commits into
mainfrom
ci/bot-app-auth

Conversation

@jdfalk

@jdfalk jdfalk commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

What changes (reusable-release.yml 2.17.0 to 2.19.0)

Scope is collect-changelog only. build-go is unchanged (default GITHUB_TOKEN checkout, no bot mint): a queue-bypassing token must not be persisted into a checkout where dependency installs, tests and GoReleaser run, and an app-pushed tag would start push: tags workflows in consumers.

  • Direct push tries the app first. collect-changelog now pushes with the app token, then the PAT, then GITHUB_TOKEN. Before, the app was only used for the fallback PR, so a ruleset bypass naming the app never helped and every collect fell through to the PR. The commit is authored as the app's bot account (user id looked up at runtime; a failed lookup only warns).
  • New optional input ci-bot-app-client-id (falls back to the caller's CI_BOT_APP_CLIENT_ID variable) and optional secret CI_BOT_APP_PRIVATE_KEY select the bot app. The legacy CI_APP_ID / CI_APP_PRIVATE_KEY pair keeps working; with neither the job behaves as before. The legacy secrets and JF_CI_GH_PAT are now declared as optional workflow_call secrets (needed once any secret is declared; secrets: inherit callers are unaffected).
  • The environment is opt-in: new input bot-environment (default empty); the job declares environment: ${{ inputs.bot-environment }}. Only a caller that holds the key as that environment's secret passes it. Outside an environment, a client id with no visible key is mode=none with a ::warning::; inside one it is an error. A key without a client id is always an error.
  • scriv runs in its own job. Separate steps of one job share $GITHUB_ENV, $GITHUB_PATH, git hooks and config, so a malicious dependency could reach a later step's token; the isolation has to be a job boundary. collect-changelog is replaced by two jobs (build-status now needs both):
    • collect-changelog-build: no environment, no secrets, permissions: contents: read. Checks out, installs scriv==1.8.0 (exact pin; its 13 transitive dependencies are not hash-pinned, which would be about 375 inline hash lines, and this job holds nothing to steal), collects, and uploads a patch limited by pathspec to CHANGELOG.md and changelog.d/. Output publish says whether there is anything to publish.
    • collect-changelog-publish: declares environment: ${{ inputs.bot-environment }}, installs nothing, fresh persist-credentials: false checkout. It downloads the patch, applies it to the index with hooks disabled, and judges the result with git's raw diff: only added, modified or deleted regular files (mode 100644) at CHANGELOG.md or under changelog.d/; renames, mode changes, symlinks and submodules are rejected. Then the app mint, the open-changelog-PR guard, the commit as the app, and the push or PR as before. I exercised the verifier locally against a good patch (accepted) and rename-out, rename-in, mode change, outside path and symlink patches (all rejected).

Prerequisites and consumers

Consumers do not get the bypass key. Only audiobook-organizer holds it, as an environment secret of its own ci-bot environment, and it will pass bot-environment: ci-bot when it re-pins (a later audiobook-organizer change, not this PR). Every other consumer passes nothing and is mode=none or mode=legacy, exactly as today. Nothing needs configuring for them.

Unverified assumption to check first

I could not confirm from the GitHub docs that environment: evaluating to an empty string means "no environment" (the docs only say the name can be an expression). The pattern environment: ${{ cond && 'name' || '' }} is widely used and is expected to run without an environment, but the first run of this workflow in a consumer that passes no bot-environment must be checked before others re-pin. If it errors, switch to an expression that yields null, or split the job.

Verification checklist

  • actionlint .github/workflows/reusable-release.yml clean (run).
  • Consumer with no bot-environment (legacy secrets or none): the release runs, the job shows no environment, mode=legacy or mode=none, behaviour unchanged.
  • audiobook-organizer after its re-pin with bot-environment: ci-bot: log shows mode=bot, "CHANGELOG.md updated for " (not "refuses direct pushes"), the changelog commit authored by the app bot (gh api "repos/<owner>/<repo>/activity?ref=<default>&per_page=1" --jq '.[0].actor.login' is <app-slug>[bot]), and no changelog/collect-* PR.
  • The build job shows no environment and no secrets in its log; the publish job log shows no pip or npm step.

Companion PR: falkcorp/audiobook-organizer (the four in-repo bot workflows).

🤖 Generated with Claude Code

https://claude.ai/code/session_011To9HQJLrCH6wYa5WCpw3L

reusable-release: build-go checks out with the app token it mints (checkout
persisted GITHUB_TOKEN, whose extraheader overrode the app token in
gha-release-go's push URL) and collect-changelog tries the app token first for
the direct push to the default branch. New optional input ci-bot-app-client-id
and secret CI_BOT_APP_PRIVATE_KEY select the CI bot app; the legacy CI_APP_*
pair still works. Both jobs run in the ci-bot environment and their mints are
narrowed with permission-* inputs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011To9HQJLrCH6wYa5WCpw3L
@github-actions github-actions Bot added size/L github-actions GitHub Actions related work type:documentation Improvements or additions to documentation module:config Configuration management workflow:github-actions GitHub Actions workflows labels Nov 7, 2026
jdfalk and others added 2 commits November 6, 2026 21:02
…plit collect

Revert build-go to its original definition: no bot mint, default checkout. A
queue-bypassing token must not be persisted into a checkout where dependency
installs, tests and GoReleaser run, and an app-pushed tag would start
push:tags workflows in consumers.

collect-changelog now takes the environment from a bot-environment input
(default none) so only a repository that owns the app key can use it, treats a
client id without a key as mode none with a warning outside an environment,
and is split so the step that installs scriv (pinned to 1.8.0) and collects
holds no token; the app token, PAT and GITHUB_TOKEN reach only the publish step,
which re-verifies the commit before pushing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011To9HQJLrCH6wYa5WCpw3L
Separate steps of one job share $GITHUB_ENV, $GITHUB_PATH, git hooks and
config, so a malicious scriv dependency could reach the publish step's token.
collect-changelog becomes collect-changelog-build (no environment, no secrets,
contents: read; installs scriv==1.8.0, collects, uploads a patch) and
collect-changelog-publish (bot-environment, installs nothing; fresh checkout,
verifies the patch touches only CHANGELOG.md and changelog.d/ as plain regular
files, applies it with hooks disabled, commits as the app, pushes or opens the
PR). build-status needs both.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011To9HQJLrCH6wYa5WCpw3L
@jdfalk
jdfalk marked this pull request as ready for review November 7, 2026 05:45
@jdfalk
jdfalk merged commit 016cd02 into main Nov 7, 2026
60 checks passed
@jdfalk
jdfalk deleted the ci/bot-app-auth branch November 7, 2026 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github-actions GitHub Actions related work module:config Configuration management size/L type:documentation Improvements or additions to documentation workflow:github-actions GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant