Fix preview links for long branch names#4469
Merged
Conversation
When a branch name produces a subdomain exceeding 63 characters (the DNS label limit), Vercel truncates it with a hash suffix. Our workflow constructed the URL independently and got it wrong in those cases. Now the workflow checks the subdomain length first. Short branch names use the constructed URL directly with no delay. Long branch names poll for the Vercel bot comment and extract the actual preview URL from its base64 payload, falling back to the constructed URL after 3 minutes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📖 Docs PR preview linksThis PR does not change any pages in /docs. If you make updates, links to the modified pages will appear here. |
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | |
Contributor
There was a problem hiding this comment.
Just a nit, but could this script be put in a file like preview-base-url.js? It's usually easier to write and maintain these scripts when they're not embedded in the workflow.
Then the package.json > "scripts" section could be updated with something like preview-base-url and then called here like: yarn run preview-base-url.
flippedcoder
approved these changes
Apr 22, 2026
Moves the inline script from the workflow into a standalone file for easier maintenance. The workflow now requires it and calls resolvePreviewUrl with the actions/github-script context. Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
vercel[bot]comment (up to 3 minutes) and extract the actual preview URL from its base64 payload, falling back to the constructed URL if the comment doesn't appear.Test plan
fix/this-is-a-very-long-branch-name-that-will-exceed-the-dns-label-limit) and confirm the workflow extracts the correct URL from the Vercel comment🤖 Generated with Claude Code
┆Attachments: EDU-6246 Fix preview links for long branch names