ci: Comment the Vercel build log on PRs whose build fails - #1946
Open
marcleblanc2 wants to merge 10 commits into
Open
ci: Comment the Vercel build log on PRs whose build fails#1946marcleblanc2 wants to merge 10 commits into
marcleblanc2 wants to merge 10 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Sep 11, 2026
Merged
marcleblanc2
force-pushed
the
marc/ci/vercel-build-failure-report
branch
from
September 11, 2026 18:01
b665669 to
e27f008
Compare
This comment has been minimized.
This comment has been minimized.
marcleblanc2
added a commit
that referenced
this pull request
Sep 11, 2026
…er line in reports (#1916) Follow-ups from testing the PR checks on #1913 / #1914. - Review comments: one suggested change per finding (not one per line), no review body. Each comment starts with an HTML marker; the workflow deletes suggestions whose finding is gone (or that GitHub could no longer place, `line: null`) and skips ones already posted, so resolved suggestions disappear like the spell check's do. - Summary comment and review comments put line, link, problem, and fix each on their own line. - Absolute links to this site get their own **Absolute links** section instead of being lumped into Outbound. - Case-mismatch findings now come with a fix (`/Code-Search/queries` → `/code-search/queries`). - Wording: "Write links on this site as relative paths", "fix the inbound links on these other pages", dropped `https://docs.sourcegraph.com/…`; reproduce command matches `package.json` (`pnpm check links …`). Tested locally against the `test-pr-checks-broken` branch with the CI recipe (baseline from `origin/main`, `--diff`, `--review`); build-mode run (`node dev/check-links.mjs`) still clean. Trade-off: when several fixes sit on one line, applying one suggestion outdates the others until the next run re-posts them, because GitHub will not batch overlapping suggestions. <!-- pr-stack-merge-order --> ## Merge order for the PR-check stack Trial-merged onto `main` in this order with no conflicts: 1. #1946 Vercel build log comment — independent; first so the other PRs' Vercel failures get a readable log 2. #1916 check-links report format — adds `dev/sync-review-comments.sh`, which #1935 calls 3. #1935 redirect check — needs #1916 merged first 4. #1947 spell check comment updates — independent 5. #1944 check-links, generated-docs sync PR — conflicts with #1916 on `dev/check-links.mjs`; rebase after #1916 merges Squash-merge each, then rebase the next onto `main`. #1948 (broken) and #1949 (fixed) are the example PRs that exercise every check; never merge, close them once the stack has landed. --------- Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
force-pushed
the
marc/ci/vercel-build-failure-report
branch
from
September 11, 2026 23:14
b33cf3b to
93ed181
Compare
marcleblanc2
enabled auto-merge (squash)
September 11, 2026 23:22
Vercel shows build logs only to members of its team, so contributors saw a red X and a login wall. On vercel.deployment.error this posts the tail of the build log on the PR; on the next successful build the same comment is updated to say the failure is fixed. Fork PRs are skipped so the project-scoped Vercel token is never used on their behalf.
…dispatch needs the file on main
Two open PRs at the same head SHA got one comment on whichever PR the
commits/{sha}/pulls API listed first. A deployment belongs to a commit,
so comment on each open PR at that head, fetching the build log once.
GitHub only resolves workflow_dispatch for workflows on the default
branch (gh workflow run --ref <branch> 404s before merge), so the header
now says to run the script locally until then.
Amp-Thread-ID: https://ampcode.com/threads/T-01a08fee-74b4-76dc-aaf9-d1245d68fdc9
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a09014-dfa8-740c-95b4-9e28c43cae51 Co-authored-by: Amp <amp@ampcode.com>
…omment cannot hold it The comment says how many lines the log has and that the last 100 are shown, matching tail -n 100. When that leaves lines out, the full log is uploaded as a workflow artifact and linked from the comment; the artifact ID rides in the comment marker so the run that reports the build passing deletes it. Amp-Thread-ID: https://ampcode.com/threads/T-01a09014-dfa8-740c-95b4-9e28c43cae51 Co-authored-by: Amp <amp@ampcode.com>
… for A deployment is built for one branch, and Vercel records that PR in the deployment's meta.githubPrId. fetch-log reads it and hands it to the comment step as pull_request, so two PRs at the same commit no longer both get the log. The success path stays off Vercel and keeps the commit lookup, since it only updates comments that already exist. The open / same-repo / head-is-this-commit checks apply either way. Amp-Thread-ID: https://ampcode.com/threads/T-01a08fee-74b4-76dc-aaf9-d1245d68fdc9 Co-authored-by: Amp <amp@ampcode.com>
…using the Vercel token fetch-log asked Vercel which PR the deployment was for, then checked GitHub that an open PR from this repository is at the commit. Swap the order, so a dispatch for a fork PR or a stale commit never spends the Vercel token. Amp-Thread-ID: https://ampcode.com/threads/T-01a08fee-74b4-76dc-aaf9-d1245d68fdc9 Co-authored-by: Amp <amp@ampcode.com>
…dential shapes A log line of four or more backticks closed the fixed fence and let the rest of the log render as Markdown in the bot comment. Make the fence one backtick longer than the longest run in the tail. The comment and artifact are public and the build gets VERCEL_OIDC_TOKEN, VERCEL_DEPLOYMENT_KEY and VERCEL_ENV_ENC_KEY, so a build that prints its environment would publish them. Redact JWTs, known token prefixes, Bearer values and TOKEN/SECRET/PASSWORD/KEY assignments before the log is written. Amp-Thread-ID: https://ampcode.com/threads/T-01a08fee-74b4-76dc-aaf9-d1245d68fdc9 Co-authored-by: Amp <amp@ampcode.com>
… failure post Looks back 30 minutes in the channel for the "failed to deploy" post for the commit, waiting up to 5 more minutes for it, then uploads the redacted log into its thread. Needs the SLACK_BOT_TOKEN secret and SLACK_CHANNEL_ID variable; skips quietly without them. Amp-Thread-ID: https://ampcode.com/threads/T-01a09292-4b20-771b-bd66-3ca16f7aad07 Co-authored-by: Amp <amp@ampcode.com>
…patterns Amp-Thread-ID: https://ampcode.com/threads/T-01a09292-4b20-771b-bd66-3ca16f7aad07 Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
force-pushed
the
marc/ci/vercel-build-failure-report
branch
from
September 11, 2026 23:23
c7d47f5 to
6e09006
Compare
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.
Problem
Vercelcheck link to the Vercel inspector, which only Vercel team members can openSolution
vercel.deployment.error(the samerepository_dispatchchannelpreview-links.ymluses), comment the tail of the build log on the PR Vercel built the deployment for (meta.githubPrId), like the links / redirects / CSpell checks do. Each PR gets its own deployment, so two PRs at the same commit each get their own commentvercel.deployment.success, update that comment to ✅ on every open PR at the commit that has one. The success path only reads PR comments; it does not touch Vercelvcp_/ghp_/github_pat_/AKIA…tokens,Bearer …,*TOKEN=/*SECRET=/*KEY=assignments) are redacted before the log is written, since the comment and artifact are public and the build getsVERCEL_OIDC_TOKEN,VERCEL_DEPLOYMENT_KEYandVERCEL_ENV_ENC_KEY. The code fence is sized longer than any backtick run in the log, so a log line cannot close it and inject MarkdownToken
VERCEL_TOKENrepo secret is a project-scoped token forsourcegraph-docsonly, expiring 2026-12-10. Vercel has no read-only scope; project scope is the narrowest it offers, and it can read and write everything in that one project/env, including?decrypt=true; the project has none), deployments list, deployment metadata, build log events, domains, custom environments, project list (returns only this project)fetch-logasks GitHub for an open PR from this repository at the commit before it contacts Vercel, so a dispatch for a fork PR or a stale commit never uses the token.repository_dispatchruns the workflow and script frommain, so a PR can't change the code the token is handed toSlack
<short sha>| sourcegraph-docs" to#alerts-vercel-doc-site. On a failure, a last step finds that post (looking back 30 minutes, then polling for up to 5 more since Vercel and this workflow are triggered by the same event) and uploads the full redacted log into its thread, linking the PR comment.continue-on-error, so a Slack problem can't hide the PR commentSLACK_BOT_TOKENrepo secret andSLACK_CHANNEL_IDrepo variable; skips quietly without them. The bot is the app indev/slack-app-vercel-build-report.json(channels:historyto find the post,files:writeto reply); it must be/invited to the channelTested
repository_dispatchnor resolvesworkflow_dispatchfor a workflow that isn't onmainyet):has no failed build to resolvecommits/{sha}/pullsAPI listed got the comment. Vercel records the PR a deployment was built for (meta.githubPrId), sofetch-lognow reads it and the comment lands on that PR only. The success path stays off Vercel and keeps the commit lookup, since it only updates comments that already existfetch-logafter the reorder: test: PR checks on a broken PR, left broken (do not merge) #1948's head →pull_request=1948; a commit with no open PR stops atNo open PR with head …withVERCEL_TOKEN=invalid, proving Vercel was not contacted. Redaction and fence sizing checked against JWT,vcp_,ghp_,AKIA…,Bearer,KEY: valuelines and a log line of six backticksgh workflow run vercel-build-report.yml -f id=dpl_... -f state=error -f sha=<pr head sha>Dry-run output (abridged)
Amp thread
Merge order for the PR-check stack
Trial-merged onto
mainin this order with no conflicts:dev/sync-review-comments.sh, which ci/redirects: Add Redirect check for PRs #1935 callsdev/check-links.mjs; rebase after check-links: one suggestion per fix, synced with findings; one fact per line in reports #1916 mergesSquash-merge each, then rebase the next onto
main.#1948 (broken) and #1949 (fixed) are the example PRs that exercise every check; never merge, close them once the stack has landed.