From 20db21237b4d790dd7e3637384bea1e1da6312c3 Mon Sep 17 00:00:00 2001 From: Teodor Calin Date: Fri, 29 May 2026 10:07:44 -0700 Subject: [PATCH] ci: post Cloudflare Pages preview URL as PR comment PR #4 added the deploy step but the wrangler-action does not auto-post a PR comment, so reviewers can't see the preview URL without digging into workflow logs (verified on PRs #12-14: deploy succeeded, comment missing). This adds a sticky comment step that uses the deployment-url output from the wrangler-action and posts (or updates) a single comment per PR via marocchino/sticky-pull-request-comment@v2. Also bumps the workflow's permissions to include pull-requests: write, which is required for the comment step. --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b71e65..1b5136f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,8 @@ permissions: contents: read # Required by wrangler-action for OIDC / deployments comment posting. deployments: write + # Required so the post-deploy step can comment the preview URL on the PR. + pull-requests: write jobs: build: @@ -38,6 +40,7 @@ jobs: # - PR from internal branch → preview (.pilotprotocol.pages.dev) # - PR from a fork → skipped (no secret access on forks) - name: Deploy to Cloudflare Pages + id: deploy if: | github.event_name == 'push' || (github.event_name == 'pull_request' && @@ -53,3 +56,20 @@ jobs: --project-name=pilotprotocol --branch=${{ github.event_name == 'push' && 'main' || github.head_ref }} --commit-dirty=true + + # Sticky comment so subsequent pushes update the same comment + # instead of stacking — keeps the PR thread clean. Header value + # must be unique per comment kind on this repo. + - name: Comment preview URL on PR + if: | + github.event_name == 'pull_request' && + steps.deploy.outputs.deployment-url + uses: marocchino/sticky-pull-request-comment@v2 + with: + header: cloudflare-pages-preview + message: | + 🚀 **Preview deployed to Cloudflare Pages** + + - Commit deploy URL: ${{ steps.deploy.outputs.deployment-url }} + - Branch alias: `https://${{ github.head_ref }}.pilotprotocol.pages.dev` (may take ~30s to propagate) + - Commit: `${{ github.event.pull_request.head.sha }}`