From 3732d4bae80e6336b6b927fb96d24e865b4b69ec Mon Sep 17 00:00:00 2001 From: Pedro Paulo Vezza Campos Date: Mon, 18 May 2026 10:07:38 -0700 Subject: [PATCH] Add per-PR preview deployment workflow Sets up Cloudflare Workers preview deployments for every pull request. Uses wrangler versions upload with preview aliases to create stable preview URLs at pr--vezza-dev.workers.dev --- .github/workflows/deploy-preview.yml | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/deploy-preview.yml diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 0000000..cbb7c3a --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,48 @@ +name: Deploy Preview + +on: + pull_request: + types: [opened, synchronize] + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '18' + + - run: npm ci + - run: npm run build + + - name: Deploy PR Preview + if: github.event_name == 'pull_request' + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: versions upload --preview-alias pr-${{ github.event.number }} + + - name: Deploy Production + if: github.event_name == 'push' + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + + - name: Comment PR with preview URL + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '🚀 Preview: https://pr-${{ github.event.number }}-vezza-dev.workers.dev' + })