Skip to content

Use a GitHub App token to update the Homebrew tap - #37

Merged
xSAVIKx merged 3 commits into
mainfrom
yuriis/sre-149-replace-homebrew_tap_token-with-a-github-app-for-dualentry
Oct 19, 2026
Merged

xSAVIKx merged 3 commits into
mainfrom
yuriis/sre-149-replace-homebrew_tap_token-with-a-github-app-for-dualentry

Conversation

@xSAVIKx

@xSAVIKx xSAVIKx commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Use a GitHub App installation token to update the Homebrew tap after a release.
  • Replace the personal access token previously used for cross-repo writes.

Test plan

  • Publish or re-run a release and confirm the tap formula PR opens
  • Remove the obsolete HOMEBREW_TAP_TOKEN repository secret

The tap update failed because the user PAT lacked CreatePullRequest.
Mint a scoped App token for homebrew-tap instead (SRE-149).
Use the shared dualentry-ci App client ID and private key names.
@xSAVIKx xSAVIKx changed the title Replace Homebrew tap PAT with dualentry-homebrew-tap App (SRE-149) Replace Homebrew tap PAT with dualentry-ci App (SRE-149) Oct 19, 2026
@xSAVIKx xSAVIKx self-assigned this Oct 19, 2026
Replace the personal access token previously required for cross-repo writes.
@xSAVIKx xSAVIKx changed the title Replace Homebrew tap PAT with dualentry-ci App (SRE-149) Use a GitHub App token to update the Homebrew tap Oct 19, 2026

@msn0 msn0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Issue Details

This PR implements SRE-149: replacing the personal access token (HOMEBREW_TAP_TOKEN) with a scoped GitHub App installation token for updating the Homebrew tap on release.

Problem: The PAT lacked CreatePullRequest permission, causing tap update failures when main is protected (requires PR + review).

Solution: Mint a scoped dualentry-ci App token with contents: write and pull-requests: write permissions.

  1. Standards

No violations of documented standards. The implementation follows GitHub Actions best practices:

  • Job-level permissions: {} correctly resets inherited permissions before granting specific ones (principle of least privilege)
  • SHA-pinned action version ensures reproducibility
  • Added set -euo pipefail improves shell safety
  • Environment variable handling is clean (no unnecessary exports or conditionals)
  1. Spec Compliance

Implemented:

  • ✅ GitHub App token creation via actions/create-github-app-token@v3.2.0
  • ✅ References DUALENTRY_CI_APP_CLIENT_ID and DUALENTRY_CI_APP_PRIVATE_KEY
  • ✅ Grants minimal permissions: contents: write, pull-requests: write
  • ✅ Scopes token to homebrew-tap repository
  • ✅ Uses token for git clone and gh pr create/merge operations
  • ✅ Removes TAP_TOKEN secret reference

Deferred per spec plan: The ticket notes HOMEBREW_TAP_TOKEN removal as a follow-up step ("Next: ... merge PR, smoke-test a release, delete HOMEBREW_TAP_TOKEN"). This is acceptable; the PR focuses on workflow implementation.

  1. Security & Quality
  • Token scoping is correct: limited to one repository, specific permissions only
  • No secrets logged or exposed in command output
  • Git clone uses standard x-access-token authentication pattern
  • Merge fallback logic preserved: attempts direct merge, then auto-merge, then warns on manual intervention
  • Change is focused and minimal (19 insertions, 6 deletions to one file)
  1. Detailed Changes

.github/workflows/release.yml:

  • Added explicit comment clarifying why App token is required (cross-repo write)
  • Added Create GitHub App token step with proper scoping
  • Replaced env.TAP_TOKEN references with steps.app-token.outputs.token via GH_TOKEN
  • Removed conditional if: ${{ env.TAP_TOKEN != '' }} (always runs now; App token auto-expires per job)
  • Removed unnecessary export GH_TOKEN="$TAP_TOKEN" line (env block is sufficient)
  • Added set -euo pipefail for safer shell execution
  • Updated comment to reflect new App token workflow
  1. Test Coverage & Verification

The PR includes a test plan in the description:

  • Publish or re-run a release and confirm the tap formula PR opens
  • Remove the obsolete HOMEBREW_TAP_TOKEN repository secret

No automation tests are required for workflow-only changes; manual release smoke-test is appropriate.

  1. Risks & Mitigations

Risk: App token generation fails if DUALENTRY_CI_APP_CLIENT_ID or DUALENTRY_CI_APP_PRIVATE_KEY are not set.
Mitigation: Workflow will fail with clear error message; secrets are already configured per ticket ("App is created and installed").

Risk: homebrew-tap repository does not have the App installed.
Mitigation: Ticket confirms installation: "App dualentry-ci created and installed (selected repos)."

  1. Readiness

Blockers: None

Ready for merge: ✅ Yes

The implementation correctly replaces PAT-based authentication with a scoped GitHub App token, improves shell safety, and maintains backward-compatible merge behavior. The deferred secret cleanup aligns with the ticket's phased plan.

@xSAVIKx
xSAVIKx merged commit fa46c9f into main Oct 19, 2026
9 checks passed
@xSAVIKx
xSAVIKx deleted the yuriis/sre-149-replace-homebrew_tap_token-with-a-github-app-for-dualentry branch October 19, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants