fix(ci): authenticate tap push via org GitHub App, not a personal PAT - #28
Conversation
The homebrew-tap workflow pushes the generated formula to the separate TechMatrix-labs/homebrew-pythinker repo, which the default GITHUB_TOKEN cannot write to, so it used a personal PAT in HOMEBREW_TAP_TOKEN. That PAT broke on the org migration and again on re-issue (authenticated but lacked Contents: write -> 403 on push), freezing the tap at 0.25.0. Replace it with a short-lived token minted at runtime from an org-owned GitHub App (actions/create-github-app-token) that has Contents: Read and write on the tap repo. The App is owned by the org (survives member/org changes), its installation token expires in ~1h and is minted fresh each run, and owner/repositories scope it to only the tap repo. Deploy keys — the simpler robust option — are disabled org-wide, so the App is the frictionless path that needs no org policy change. Requires two secrets on this repo: HOMEBREW_TAP_APP_ID and HOMEBREW_TAP_APP_PRIVATE_KEY. The old HOMEBREW_TAP_TOKEN secret is no longer referenced and can be deleted.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe workflow replaces static PAT authentication with a minted short-lived GitHub App token for the Homebrew tap repository. A new step uses app credentials and environment variables to create the token, and the subsequent sync step uses that token while updating its error message to reflect the new authentication method. ChangesGitHub App Token Authentication for Homebrew Tap
Sequence Diagram(s)sequenceDiagram
participant Runner as GitHub Actions Runner
participant TokenAction as actions/create-github-app-token
participant TapSync as "Sync formula into tap repo"
participant TapRepo as Tap repository (${TAP_OWNER}/${TAP_REPO})
Runner->>TokenAction: provide HOMEBREW_TAP_APP_ID & HOMEBREW_TAP_APP_PRIVATE_KEY
TokenAction-->>Runner: outputs steps.app-token.outputs.token
Runner->>TapSync: set TAP_TOKEN=steps.app-token.outputs.token
TapSync->>TapRepo: push/sync formulas using TAP_TOKEN
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/homebrew-tap.yml:
- Around line 79-86: Replace movable action tags with immutable commit SHAs:
change uses: actions/create-github-app-token@v2 to uses:
actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349, and
similarly pin uses: actions/checkout@v4 and uses: actions/setup-python@v5 to
their respective full commit SHAs (replace the `@vX` tags with the full commit IDs
you fetch from each repo). Also ensure the GitHub App installation permissions
are restricted to only "Contents: Read and write" for the installation on the
TAP owner/repo (the ${TAP_OWNER}/${TAP_REPO} installation) in the app settings
so the minted token scoped by owner/repositories is limited to that permission.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 8388c4e8-7c4b-430f-8048-2227aa7825b4
📒 Files selected for processing (1)
.github/workflows/homebrew-tap.yml
This action mints an installation token from the tap App's private key, so pin it to an immutable commit (v2.2.2) rather than the movable v2 tag to remove the supply-chain risk of a retagged release exfiltrating the key. Addresses CodeRabbit review on #28.
Problem
homebrew-tap.ymlpushes the generated formula to the separateTechMatrix-labs/homebrew-pythinkerrepo, which the defaultGITHUB_TOKENcan't write to — so it used a personal PAT inHOMEBREW_TAP_TOKEN. That PAT broke on the org migration and again on re-issue: it authenticated asmohamed-elkholy95but lackedContents: write, so everygit push403'd and the tap froze at 0.25.0 (current latest release is 0.26.0).Fix
Mint a short-lived installation token at runtime from an org-owned GitHub App (
actions/create-github-app-token@v2) scoped to the tap repo withContents: Read and write:owner/repositorieslimit the token to onlyhomebrew-pythinker.Deploy keys (the simpler robust option) are disabled org-wide for
TechMatrix-labs, so the App is the frictionless path that needs no org-policy change. The HTTPSx-access-token:<token>@github.com/...push is unchanged — only the token source moved.Required secrets (set on
TechMatrix-labs/pythinker-code)HOMEBREW_TAP_APP_IDHOMEBREW_TAP_APP_PRIVATE_KEY.pemprivate keyThe old
HOMEBREW_TAP_TOKENsecret is no longer referenced and can be deleted after this lands.Verification
After the App is created/installed and the secrets are set: re-run
homebrew-tap.ymlfor 0.26.0 and confirm the tap formula flips to 0.26.0. (Tracked separately; this PR is the workflow wiring only.)Summary by CodeRabbit