Skip to content

storefront-worker: get the publish token from the gateway over a service binding - #225

Merged
HereLiesAz merged 1 commit into
mainfrom
claude/amazing-fermi-3o92qn-token
Sep 27, 2026
Merged

HereLiesAz merged 1 commit into
mainfrom
claude/amazing-fermi-3o92qn-token

Conversation

@HereLiesAz

@HereLiesAz HereLiesAz commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

POST /packages no longer needs a GitHub secret. It asks HereLiesAz/workflows' gateway Worker for a token over a Cloudflare service binding.

  • wrangler.jsonc: services: [{ binding: "GITHUB_TOKENS", service: "workflows", entrypoint: "RepositoryTokens" }].
  • src/publish.ts:
    • Calls GITHUB_TOKENS.azphaltPublishToken() for a one-hour App installation token limited to HereLiesAz/azphalt (contents and pull-requests write).
    • Fetches the token only after the package verifies, so a bad upload never mints one. A failed mint answers 503 unavailable.
    • A fixed GITHUB_PUBLISH_TOKEN still wins, as an override for deployments without the gateway. With neither, the endpoint answers 501, as before.
  • README § Secrets: no GitHub secret to set. Explains the binding, and that the App needs those two permissions.
  • Changeset.

Merge order: after HereLiesAz/workflows#82, which adds the RepositoryTokens entrypoint. Until that deploys, the binding has nothing to call, so publishes answer 503.

Validation

  • Worker: 25 tests pass, including new ones. They check that the minted token is what reaches GitHub, that nothing is minted for a package that fails verification, that the fixed-token override wins, and that a mint failure gives 503. typecheck passes.
  • Ran both Workers together under wrangler dev (real workerd). The binding reached the gateway's entrypoint and the gateway called GitHub; its App error came back as 503.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QwYWVPse8spRrfMMcuTJPv

@vercel

vercel Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
azphalt Ready Ready Preview Sep 27, 2026 5:20am UTC

@sourcery-ai

sourcery-ai Bot commented Sep 27, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Documentation now describes the centralized deployment flow for GITHUB_PUBLISH_TOKEN: the shared workflow forwards GH_TOKEN after deployment, replacing manual secret provisioning; no application code changes are included.

Sequence diagram for centralized GitHub token provisioning

sequenceDiagram
    participant Workflow as CentralDeployWorkflow
    participant Worker as StorefrontWorker
    participant GitHub as GitHubRepository
    Workflow->>Worker: Deploy Worker
    Workflow->>Worker: Forward GH_TOKEN as GITHUB_PUBLISH_TOKEN
    Worker->>GitHub: POST /packages using GITHUB_PUBLISH_TOKEN
    GitHub-->>Worker: Contents and pull request access
Loading

File-Level Changes

Change Details Files
Update deployment documentation to reflect that the publish token is injected automatically by the shared Cloudflare deployment workflow.
  • Remove the manual Wrangler secret command for GITHUB_PUBLISH_TOKEN.
  • Document that the workflow forwards GH_TOKEN when the Worker’s purpose profile includes worker_secrets.
  • Retain the required permissions, repository, and failure behavior for package publishing.
  • Align the PUBLISH_REPOSITORY comment with the centralized token flow.
apps/storefront-worker/README.md
apps/storefront-worker/wrangler.jsonc

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

…ice binding

POST /packages now asks HereLiesAz/workflows' gateway Worker for a GitHub
token through the GITHUB_TOKENS service binding (RepositoryTokens entrypoint):
a one-hour App installation token narrowed to HereLiesAz/azphalt with
contents and pull-requests write. It is fetched only after the package
verifies; a failed mint answers 503. The Worker keeps no GitHub secret; a
fixed GITHUB_PUBLISH_TOKEN stays as an override for self-hosted deploys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QwYWVPse8spRrfMMcuTJPv
@HereLiesAz
HereLiesAz force-pushed the claude/amazing-fermi-3o92qn-token branch from 8890aa0 to da52070 Compare September 27, 2026 05:20
@HereLiesAz HereLiesAz changed the title storefront-worker: GITHUB_PUBLISH_TOKEN comes from the central GH_TOKEN storefront-worker: get the publish token from the gateway over a service binding Sep 27, 2026

Copy link
Copy Markdown
Owner Author

Two checks fail on this PR, and neither comes from it:

  • github-advanced-security: Copilot rejects the model it's set to use (sweagent-capi:claude-opus-5). The fix is a repository setting, not code.
  • Analyze (java-kotlin): codeql.yml on main tries to auto-build Kotlin from the repo root and fails; it fails on main too. A proposed patch is in my comment on #222.

Sourcery's reviewer's guide describes this PR's first version, which forwarded GH_TOKEN. That approach has been replaced by the service binding in the current commit.


Generated by Claude Code

@HereLiesAz
HereLiesAz marked this pull request as ready for review September 27, 2026 05:36

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @HereLiesAz, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 16 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@HereLiesAz
HereLiesAz merged commit f053350 into main Sep 27, 2026
8 of 10 checks passed
@HereLiesAz
HereLiesAz deleted the claude/amazing-fermi-3o92qn-token branch September 27, 2026 05:36

This branch was successfully deployed

1 active deployment
Preview — da520702 Deployed Sep 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants