Add per-PR preview deployment workflow#3
Closed
pedropaulovc wants to merge 1 commit into
Closed
Conversation
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
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
vezza-dev | 3732d4b | Commit Preview URL | May 18 2026, 05:08 PM |
There was a problem hiding this comment.
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.ymlto build and deploy PR previews viawrangler versions upload --preview-alias ... - Deploys to production on
pushtomainviacloudflare/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_requestsynchronize, so thecreateCommentcall 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_requestwill 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Testing per-PR deployment setup with Cloudflare Workers preview aliases.
Each PR will automatically deploy to:
pr-<number>-vezza-dev.workers.devSetup required
Before this workflow will deploy:
CLOUDFLARE_API_TOKENsecret (create at https://dash.cloudflare.com/?to=/:account/api-tokens)CLOUDFLARE_ACCOUNT_IDsecret (find at https://dash.cloudflare.com/)How it works
pr-<number>-vezza-dev.workers.dev