ci: post the Cloudflare preview URL as a PR comment - #173
Merged
Conversation
Cloudflare's GitHub App stopped commenting on this repo's PRs after Jul 30 (#171 and #172 got none), while its `Workers Builds` check run kept arriving with the preview URLs in its summary. Read them off the check run and post the comment with our own GITHUB_TOKEN instead. Adapted from tightknit-app's cf-preview-urls.yml, minus the parts that only mattered there: no multi-worker aggregation, no constructed fallback URLs, and the commit-ordering guard replaced by a plain head-SHA equality check. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Cloudflare's GitHub App stopped commenting preview URLs on this repo's PRs. Every PR from #155 to #170 got the
cloudflare-workers-and-pages[bot]comment (except #164, which lost it to a five-PR dependabot burst); both PRs opened since, #171 and #172, got nothing. TheWorkers Builds: block-kitchencheck run still arrives and passes, posted by the same app (id 85455), and its summary still carries the URLs:Both resolve, so only the comment is missing. The org installation was updated Aug 3 at 16:27 PT, the day before the first silent PR, and currently grants
administration, checks, contents, deployments, metadata, pull_requestswith noissuesgrant. That is a plausible cause but not confirmed, and it is on Cloudflare's side either way. This reads the URLs off the check run and posts the comment with our ownGITHUB_TOKEN, so it does not depend on that app's comment permissions at all.What
.github/workflows/cf-preview-url.yml, adapted from tightknit-app'scf-preview-urls.yml. Trigger oncheck_run: completed, filter to the Cloudflare app, resolve the PR by branch, parse the two URLs out ofoutput.summary, then create or update a comment keyed by a<!-- cf-preview-url -->marker.Dropped from the original, none of which apply to a single-worker repo:
EXPECTED_WORKERSlist and the per-worker aggregation tablechecks.listForRefcall (thecheck_runevent payload already carries this worker'soutput.summary)compareCommitsWithBaseheadordering guard, replaced by a plainsha !== pr.head.shaskipThat last one is the only behavior change worth naming: a build that finishes after a newer push posts nothing instead of being ordered against the recorded commit. The newer build's own check run posts moments later, so the end state is the same and the comment can never show stale results.
Rendered output:
Verification
The YAML parses, and the inline script, extracted verbatim from the file, was dry-run against the real check-run payload from #172 with a stubbed Octokit:
This will not demonstrate itself on this PR. GitHub only dispatches
check_runevents to workflow files already on the default branch, so the first PR to get a comment is the one after this merges. If it stays silent then, the next thing to check is whether Cloudflare's own comment was disabled at the source (Workers → block-kitchen → Settings → Builds), since this workflow depends on the check run continuing to arrive.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.