-
-
Notifications
You must be signed in to change notification settings - Fork 16
Integrate Vercel Preview Deployments in CI Workflow #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
KanishkSogani
merged 6 commits into
StabilityNexus:main
from
aniket866:Integrate-vercel-preview
Feb 4, 2026
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2d7b525
Integrate-github-and-vercel-preview
aniket866 573c9ba
code Rabbit :Update .github/workflows/vercel-preview.yml
aniket866 9e2ec72
fixed vercel preview for development-phase only
aniket866 1bb4ad7
Delete .github/workflows/vercel-preview.yml
aniket866 d7bfd4a
Update nextjs.yml
aniket866 6ede6e0
Update nextjs.yml
aniket866 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| name: PR Preview (GitHub Pages) | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, closed] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| preview: | ||
| if: github.event.action != 'closed' | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| cache: "npm" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build with dynamic BasePath | ||
| run: npm run build | ||
| env: | ||
| # Informs Next.js that it is hosted at /repo-name/pr-number/ | ||
| BASE_PATH: /${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }} | ||
|
|
||
| - name: Prepare preview folder | ||
| run: | | ||
| mkdir -p preview/pr-${{ github.event.pull_request.number }} | ||
| cp -r out/* preview/pr-${{ github.event.pull_request.number }} | ||
|
|
||
| - name: Deploy to GitHub Pages | ||
| uses: peaceiris/actions-gh-pages@v4 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: preview | ||
| keep_files: true # Prevents the main site and other PRs from being deleted | ||
|
|
||
| - name: Comment preview URL | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const url = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr-${context.payload.pull_request.number}/`; | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.payload.pull_request.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: `**Preview deployed:**\n${url}` | ||
| }) | ||
|
|
||
| cleanup: | ||
| if: github.event.action == 'closed' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout gh-pages | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: gh-pages | ||
|
|
||
| - name: Remove preview folder | ||
| run: | | ||
| rm -rf pr-${{ github.event.pull_request.number }} | ||
|
|
||
| - name: Commit and Push cleanup | ||
| uses: peaceiris/actions-gh-pages@v4 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: . |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| name: Vercel Preview Deployment | ||
| env: | ||
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | ||
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | ||
| on: | ||
| pull_request: | ||
| branches: ["main"] | ||
|
|
||
| jobs: | ||
| deploy-preview: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Vercel CLI | ||
| run: npm install --global vercel@latest | ||
|
|
||
| - name: Pull Vercel Environment Information | ||
| run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | ||
|
|
||
| - name: Build Project Artifacts | ||
| run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | ||
|
|
||
| - name: Deploy Project Artifacts to Vercel | ||
| id: deploy | ||
| run: | | ||
| COMMAND_OUTPUT=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) | ||
| echo "preview_url=$COMMAND_OUTPUT" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Comment on PR | ||
| uses: thollander/actions-comment-pull-request@v2 | ||
| with: | ||
| message: | | ||
| Vercel Preview Deployment is ready! | ||
| **URL**: ${{ steps.deploy.outputs.preview_url }} | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.