Integrate Vercel Preview Deployments in CI Workflow#25
Conversation
📝 WalkthroughWalkthroughAdds two GitHub Actions workflows to automate PR preview deployments—one for GitHub Pages with built-in cleanup on PR closure, another for Vercel with inline deployment comments. Also extends Next.js configuration to support dynamic base paths via the Changes
Sequence DiagramssequenceDiagram
participant GH as GitHub (PR Event)
participant Actions as GitHub Actions
participant Runner as Node Build Runner
participant Pages as GitHub Pages
participant API as GitHub API
GH->>Actions: PR opened / updated
Actions->>Runner: checkout, setup Node, npm install
Runner->>Runner: build with BASE_PATH
Runner->>Pages: copy to preview/pr-<N> & publish
Pages-->>Pages: merge/preserve existing gh-pages content
Actions->>API: post PR comment with preview URL
sequenceDiagram
participant GH as GitHub (PR Event)
participant Actions as GitHub Actions
participant VercelCLI as Vercel CLI
participant Vercel as Vercel Platform
participant API as GitHub API
GH->>Actions: PR opened / updated
Actions->>VercelCLI: install & pull env (using token)
VercelCLI->>Vercel: build artifacts / deploy prebuilt
Vercel-->>VercelCLI: return deployment URL
Actions->>API: post PR comment with preview URL
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/vercel-preview.yml:
- Around line 1-8: Add explicit GITHUB_TOKEN permissions to the workflow by
adding a permissions block that grants at minimum issues: write so the
thollander/actions-comment-pull-request@v2 step can post comments; update the
top-level workflow (name: Vercel Preview Deployment) to include permissions: {
issues: write } and, if you must comment on PRs from forks, consider switching
the trigger to pull_request_target or using a PAT stored in secrets and
referenced by the commenting step (ensure you update the step using
thollander/actions-comment-pull-request@v2 accordingly).
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
Hey @aniket866, you mentioned three things in one place - VERCEL_TOKEN, VERCEL_ORG_ID, and VERCEL_PROJECT_ID but later you only mentioned VERCEL_ORG_ID and VERCEL_PROJECT_ID. Could you please confirm which secrets actually need to be added? Also, I checked my Vercel account settings and I can only find the User ID there, nothing else. |
|
hi @KanishkSogani you were right , I by-mistake added vercel configuration for the Production level but since we are in development phase we don't require any token or project -Id ( these are required when project for production level not in dev phase). I have corrected the implementation , Now one thing you have to do just deploy this reop in your vercel and all set ! sorry for the mistake |
|
Ok @aniket866 but if I deploy this repo on Vercel, won’t we get link previews only after the PR is merged, not when the PR is created? |
I think it is configured to build ,it should work, let's see if it won't work |
Description
Enabled Vercel PR previews via Vercel GitHub integration (auto-deployed on each PR with link attached).
Removed GitHub Pages–based PR previews to avoid duplication and failures.
Thankyou so much
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.