Skip to content

Add per-PR preview deployment workflow#3

Closed
pedropaulovc wants to merge 1 commit into
mainfrom
test/dummy-pr
Closed

Add per-PR preview deployment workflow#3
pedropaulovc wants to merge 1 commit into
mainfrom
test/dummy-pr

Conversation

@pedropaulovc
Copy link
Copy Markdown
Collaborator

Testing per-PR deployment setup with Cloudflare Workers preview aliases.

Each PR will automatically deploy to: pr-<number>-vezza-dev.workers.dev

Setup required

Before this workflow will deploy:

  1. Add CLOUDFLARE_API_TOKEN secret (create at https://dash.cloudflare.com/?to=/:account/api-tokens)
  2. Add CLOUDFLARE_ACCOUNT_ID secret (find at https://dash.cloudflare.com/)

How it works

  • PRs: Deploy to preview at pr-<number>-vezza-dev.workers.dev
  • Push to main: Deploy to production
  • Auto-comments on PRs with the preview URL

Sets up Cloudflare Workers preview deployments for every pull request.
Uses wrangler versions upload with preview aliases to create stable
preview URLs at pr-<number>-vezza-dev.workers.dev
Copilot AI review requested due to automatic review settings May 18, 2026 17:07
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
vezza-dev 3732d4b Commit Preview URL May 18 2026, 05:08 PM

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a GitHub Actions workflow to deploy Cloudflare Workers per pull request (using preview aliases) and deploy to production on pushes to main, with an automatic PR comment linking the preview URL.

Changes:

  • Introduces .github/workflows/deploy-preview.yml to build and deploy PR previews via wrangler versions upload --preview-alias ...
  • Deploys to production on push to main via cloudflare/wrangler-action@v3
  • Posts a PR comment containing the preview URL for each PR run
Comments suppressed due to low confidence (2)

.github/workflows/deploy-preview.yml:48

  • This workflow runs on every pull_request synchronize, so the createComment call will add a new comment on every push and can quickly spam the PR timeline. Consider upserting a single comment (e.g., search for an existing bot comment containing the preview URL and update it) instead of always creating a new one.
      - 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'
            })

.github/workflows/deploy-preview.yml:30

  • Deploying on pull_request will run for forked PRs too, but GitHub does not provide repository secrets to workflows triggered from forks. That means the deploy step will fail noisily for external contributors. Add a guard (e.g., if: github.event.pull_request.head.repo.fork == false) or otherwise skip deploy/commenting when secrets aren't available.
      - 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 }}


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jobs:
deploy:
runs-on: ubuntu-latest
permissions:

jobs:
deploy:
runs-on: ubuntu-latest
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.

3 participants