Skip to content

ci: Add ephemeral preview deployments for pull requests#43

Open
znat wants to merge 3 commits intomainfrom
claude/ephemeral-pr-deployments-zsIQ1
Open

ci: Add ephemeral preview deployments for pull requests#43
znat wants to merge 3 commits intomainfrom
claude/ephemeral-pr-deployments-zsIQ1

Conversation

@znat
Copy link
Copy Markdown
Owner

@znat znat commented May 7, 2026

Summary

This PR adds a new GitHub Actions workflow that automatically deploys ephemeral preview builds to Vercel for each pull request, allowing reviewers to test CLI changes in a live environment before merging.

Key Changes

  • New workflow: deploy-vercel-preview.yml that triggers on PR events (opened, synchronize, reopened)
  • In-repo CLI builds: Builds the CLI from the PR's source code instead of using the published package, ensuring CLI changes are actually tested in the preview
  • Incremental analysis: Restores analyzer state from production to make PR runs incremental rather than full re-analyses
  • Sticky PR comments: Posts a single updating comment with the preview URL rather than one per push
  • Fork PR safety: Skips fork PRs since secrets aren't available in pull_request events
  • Smart concurrency: Cancels in-flight builds when newer commits are pushed to the same PR
  • Auto-expiration: Leverages Vercel's built-in preview retention policy instead of requiring manual cleanup

Implementation Details

  • Reuses existing Vercel secrets (VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID) and MINIMAX_API_KEY
  • Uses --prebuilt flag with Vercel CLI to deploy pre-built output without triggering Vercel's build system
  • Omits --prod flag to generate unique preview URLs per build
  • Includes proper error handling with set -euo pipefail in shell steps
  • Requires pull-requests: write permission for posting sticky comments

https://claude.ai/code/session_019V8WesTVrDcAovLA1tSfPy

Summary by CodeRabbit

  • Chores
    • Added automated preview deployments for pull requests: preview builds run on PR events, upload prebuilt artifacts, and post a single sticky PR comment with the preview URL (updated on subsequent runs). In-flight preview runs are canceled when superseded to keep PRs current and simplify testing and review.

Each PR push builds the in-repo CLI from source, runs analyze + build,
and deploys to a unique Vercel preview URL posted back as a sticky PR
comment. Lets reviewers click through and validate site output before
merging. Fork PRs are skipped (no secrets exposure under pull_request).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3de4c099-06af-428c-a5a9-047eb4c12f5b

📥 Commits

Reviewing files that changed from the base of the PR and between b1ba2aa and 12491aa.

📒 Files selected for processing (1)
  • .github/workflows/deploy-vercel-preview.yml

📝 Walkthrough

Walkthrough

A new GitHub Actions workflow deploys ephemeral Vercel previews for same-repository pull requests. It checks out code, sets up Node.js and builds the in-repo CLI, runs cli analyze and cli build, stages Vercel prebuilt output, deploys with vercel deploy --prebuilt, captures the preview URL, and posts/updates a sticky PR comment.

Changes

PR Preview Deployment Workflow

Layer / File(s) Summary
Workflow Setup & Configuration
.github/workflows/deploy-vercel-preview.yml
Defines workflow triggers (PR opened/synchronize/reopened), required permissions, PR-number-scoped concurrency with cancel-in-progress, and a guard to skip fork PRs.
CLI Setup & Analysis
.github/workflows/deploy-vercel-preview.yml
Checks out repo, sets up Node.js (v22) with yarn caching, installs and builds the in-repo @gitpulse/cli, and runs cli analyze with Minimax/OpenAI env vars and GITPULSE_SITE_URL.
Site Build
.github/workflows/deploy-vercel-preview.yml
Runs cli build with GITPULSE_BASE_PATH=none to produce site artifacts under .gitpulse/out.
Vercel Output Staging
.github/workflows/deploy-vercel-preview.yml
Creates .vercel/output structure, writes config.json { "version": 3 }, and copies .gitpulse/out into .vercel/output/static.
Deployment & URL Capture
.github/workflows/deploy-vercel-preview.yml
Installs pinned major vercel@53 CLI, runs vercel deploy --prebuilt --yes with secrets, and captures the preview URL into GITHUB_OUTPUT.
PR Comment with Preview URL
.github/workflows/deploy-vercel-preview.yml
Posts or updates a sticky PR comment labeled vercel-preview containing the preview URL and PR head SHA; updates the same header with a failure message linking the workflow run on failure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • znat/gitpulse#35: Both PRs add workflows that run the @gitpulse/cli analyze/build, stage prebuilt Vercel output, and deploy with the vercel CLI.
  • znat/gitpulse#39: Related CI workflow changes for how the @gitpulse/cli is installed/invoked in GitHub Actions; overlaps in preview/deploy patterns.

Poem

🐰 I hopped through code with care,
Built the CLI and output to share,
Staged the files in tidy rows,
Deployed a preview where it shows,
A PR link gleams — hop, view, and stare!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new CI workflow for ephemeral Vercel preview deployments on pull requests, which matches the core purpose of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/ephemeral-pr-deployments-zsIQ1

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 7, 2026

Greptile Summary

Adds a new GitHub Actions workflow that builds an in-repo CLI from PR source, runs analysis + site generation, and deploys the result to Vercel as a unique ephemeral preview URL, posted back as a sticky PR comment.

  • Fork-PR guard and concurrency: same-repo check prevents secrets leakage to forks; cancel-in-progress: true ensures only the latest commit's preview is deployed.
  • In-repo CLI build: yarn workspace @gitpulse/cli build replaces the published package so uncommitted CLI changes are exercised in the preview — the canonical site URL (GITPULSE_SITE_URL) intentionally stays pointed at production to enable incremental state restore.
  • Third-party action unpinned: marocchino/sticky-pull-request-comment@v2 runs with pull-requests: write but is not locked to an immutable SHA, creating a supply-chain exposure.

Confidence Score: 4/5

The workflow is well-structured and safe to merge; the only concern worth resolving before long-term use is pinning the third-party comment action to a commit SHA.

The core logic — fork guard, concurrency cancellation, in-repo CLI build, prebuilt Vercel deploy, and sticky comment — is all correctly implemented and mirrors the production workflow's patterns. The unpinned marocchino/sticky-pull-request-comment@v2 action runs with pull-requests: write access each time a PR is pushed, which is a real but limited exposure. The missing Yarn cache is a convenience improvement, not a correctness issue.

.github/workflows/deploy-vercel-preview.yml — specifically the third-party action reference at line 97.

Security Review

  • Supply chain risk (marocchino/sticky-pull-request-comment@v2): third-party action pinned to a mutable tag executes with pull-requests: write and GITHUB_TOKEN access; a tag overwrite could allow unauthorized comment posting or token exposure. Pin to a commit SHA.

Important Files Changed

Filename Overview
.github/workflows/deploy-vercel-preview.yml New workflow for ephemeral Vercel preview deployments on PRs; correctly guards against fork PRs, uses smart concurrency, and posts sticky comments — third-party action is unpinned by SHA and Yarn caching is missing

Fix All in Claude Code

Reviews (1): Last reviewed commit: "feat(ci): add ephemeral Vercel preview d..." | Re-trigger Greptile

VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

- name: Comment preview URL on PR (sticky)
uses: marocchino/sticky-pull-request-comment@v2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 security The third-party action is pinned to a mutable tag (v2) rather than an immutable commit SHA. If the v2 tag is ever force-pushed (accidentally or maliciously), the workflow would execute the updated code with pull-requests: write access and the GITHUB_TOKEN. Pinning to the exact SHA the tag currently resolves to eliminates that exposure.

Suggested change
uses: marocchino/sticky-pull-request-comment@v2
uses: marocchino/sticky-pull-request-comment@<current-sha> # v2

Fix in Claude Code

Comment on lines +45 to +47
- uses: actions/setup-node@v6
with:
node-version: 22
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The setup-node step doesn't enable Yarn caching. Every PR run does a fresh yarn install. Adding cache: 'yarn' restores the cache from a prior run if the lockfile hasn't changed, cutting the install step from tens of seconds to near-zero on cache hits.

Suggested change
- uses: actions/setup-node@v6
with:
node-version: 22
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'yarn'

Fix in Claude Code

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/deploy-vercel-preview.yml:
- Around line 86-90: Remove the --token="$VERCEL_TOKEN" flag from the vercel
deploy command so the CLI reads VERCEL_TOKEN from the environment; update the
run block that currently contains vercel deploy --prebuilt --yes
--token="$VERCEL_TOKEN" to simply call vercel deploy --prebuilt --yes and ensure
the workflow continues to set VERCEL_TOKEN in env so the CLI picks it up
natively.
- Line 88: Replace the unpinned global install "npm install -g vercel@latest"
with a pinned CLI version to avoid accidental breaking changes; update the
workflow to use a specific version string (or a VERCEL_CLI_VERSION variable)
instead of `@latest` and ensure the workflow step that runs the deploy and
captures URL (the URL=$(vercel deploy ...) usage) uses that pinned install so
the stdout contract remains stable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 034d8e71-eac2-4bae-a6ff-dc7e2352ff92

📥 Commits

Reviewing files that changed from the base of the PR and between 403c836 and c8889a2.

📒 Files selected for processing (1)
  • .github/workflows/deploy-vercel-preview.yml

Comment thread .github/workflows/deploy-vercel-preview.yml
Comment thread .github/workflows/deploy-vercel-preview.yml Outdated
- Pin marocchino/sticky-pull-request-comment to commit SHA (v2.9.4) —
  matches the SHA-pin convention already used in lint-pr-title.yml;
  Dependabot will rotate it.
- Drop `--token` flag from `vercel deploy` — VERCEL_TOKEN is already
  in env, the flag exposed it in /proc/<pid>/cmdline.
- Pin `vercel` CLI to v53 instead of @latest, so a future
  semver-breaking release can't silently break URL capture.
- Enable Yarn cache on setup-node to speed up `yarn install`.
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

znat has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/deploy-vercel-preview.yml:
- Around line 101-111: The "Comment preview URL on PR (sticky)" step uses
marocchino/sticky-pull-request-comment and runs only on success, leaving a stale
comment when deploy fails; update the workflow so this step runs regardless of
job success (e.g., add if: always() to the step) and change the message to
reflect failure when steps.deploy.outputs.url is unavailable (use
github.event.pull_request.head.sha and conditionally output a failure note or a
blank/removed URL) so the sticky comment is updated on both success and failure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a124cc29-7e9b-43c4-9b9f-f268e54fbeff

📥 Commits

Reviewing files that changed from the base of the PR and between c8889a2 and b1ba2aa.

📒 Files selected for processing (1)
  • .github/workflows/deploy-vercel-preview.yml

Comment thread .github/workflows/deploy-vercel-preview.yml
@znat znat changed the title Add ephemeral preview deployments for pull requests ci: Add ephemeral preview deployments for pull requests May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Vercel preview — built from 12491aa5b7999115dbdd07988cd811079fca948e

https://gitpulse-23dvso6du-znats-projects.vercel.app

Without an `if:` guard, the comment step only runs on success, so a
later failed run would leave the previous run's URL/SHA pinned at the
top of the PR. Splits into success/failure variants sharing the same
sticky header so the comment always reflects the latest run.
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

znat has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants