Skip to content

Adding previews for PRs #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 'Preview Deployment'
on:
pull_request_target:
branches:
- master

jobs:
deploy:
permissions:
actions: read
contents: read
deployments: write
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Cache node_modules
uses: actions/cache@v4
with:
path: node_modules/
key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }}

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
cache-dependency-path: ./package-lock.json

- name: Install dependencies
run: npm ci

- name: Build package
id: build-package
run: npm run build
env:
BASE_PATH: /
URL: https://betaflight.com
ORG: betaflight

- name: Deploy to Cloudflare
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy build --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch ${{ github.head_ref }} --commit-dirty=true

- name: Add deployment comment
uses: thollander/actions-comment-pull-request@v3
with:
message: |
Preview URL: ${{ steps.deploy.outputs.deployment-url }}
reactions: eyes, rocket
comment-tag: 'Preview URL'
mode: recreate
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- uses: actions/setup-node@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
Expand Down