From 6a045db72ba6a25d84e2bf16f577875751bcf35a Mon Sep 17 00:00:00 2001 From: Jamison Lahman Date: Tue, 10 Feb 2026 16:58:59 -0800 Subject: [PATCH] chore(devtools): deploy preview frontend builds in CI (#8315) --- .github/workflows/preview.yml | 73 +++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000000..92358a9118 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,73 @@ +name: Preview Deployment +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_CLI: vercel@50.14.1 +on: + push: + branches-ignore: + - main + paths: + - "web/**" +permissions: + contents: read + pull-requests: write +jobs: + Deploy-Preview: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + with: + persist-credentials: false + + - name: Setup node + uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # ratchet:actions/setup-node@v4 + with: + node-version: 22 + cache: "npm" + cache-dependency-path: ./web/package-lock.json + + - name: Pull Vercel Environment Information + run: npx --yes ${{ env.VERCEL_CLI }} pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: npx --yes ${{ env.VERCEL_CLI }} build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + id: deploy + run: | + DEPLOYMENT_URL=$(npx --yes ${{ env.VERCEL_CLI }} deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) + echo "url=$DEPLOYMENT_URL" >> "$GITHUB_OUTPUT" + + - name: Update PR comment with deployment URL + if: always() && steps.deploy.outputs.url + env: + GH_TOKEN: ${{ github.token }} + DEPLOYMENT_URL: ${{ steps.deploy.outputs.url }} + run: | + # Find the PR for this branch + PR_NUMBER=$(gh pr list --head "$GITHUB_REF_NAME" --json number --jq '.[0].number') + if [ -z "$PR_NUMBER" ]; then + echo "No open PR found for branch $GITHUB_REF_NAME, skipping comment." + exit 0 + fi + + COMMENT_MARKER="" + COMMENT_BODY="$COMMENT_MARKER + **Preview Deployment** + + | Status | Preview | Commit | Updated | + | --- | --- | --- | --- | + | ✅ | $DEPLOYMENT_URL | \`${GITHUB_SHA::7}\` | $(date -u '+%Y-%m-%d %H:%M:%S UTC') |" + + # Find existing comment by marker + EXISTING_COMMENT_ID=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ + --jq ".[] | select(.body | startswith(\"$COMMENT_MARKER\")) | .id" | head -1) + + if [ -n "$EXISTING_COMMENT_ID" ]; then + gh api "repos/$GITHUB_REPOSITORY/issues/comments/$EXISTING_COMMENT_ID" \ + --method PATCH --field body="$COMMENT_BODY" + else + gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY" + fi