Skip to content

Commit 033890d

Browse files
authored
Adding previews for PRs (#552)
1 parent 8685736 commit 033890d

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

.github/workflows/deploy-preview.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: 'Preview Deployment'
2+
on:
3+
pull_request_target:
4+
branches:
5+
- master
6+
7+
jobs:
8+
deploy:
9+
permissions:
10+
actions: read
11+
contents: read
12+
deployments: write
13+
pull-requests: write
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Cache node_modules
21+
uses: actions/cache@v4
22+
with:
23+
path: node_modules/
24+
key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
25+
26+
- name: Setup node
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 18
30+
cache: npm
31+
cache-dependency-path: ./package-lock.json
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Build package
37+
id: build-package
38+
run: npm run build
39+
env:
40+
BASE_PATH: /
41+
URL: https://betaflight.com
42+
ORG: betaflight
43+
44+
- name: Deploy to Cloudflare
45+
id: deploy
46+
uses: cloudflare/wrangler-action@v3
47+
with:
48+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
49+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
50+
command: pages deploy build --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch ${{ github.head_ref }} --commit-dirty=true
51+
52+
- name: Add deployment comment
53+
uses: thollander/actions-comment-pull-request@v3
54+
with:
55+
message: |
56+
Preview URL: ${{ steps.deploy.outputs.deployment-url }}
57+
reactions: eyes, rocket
58+
comment-tag: 'Preview URL'
59+
mode: recreate

.github/workflows/deploy.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
- name: Checkout code
1414
uses: actions/checkout@v4
1515

16-
- uses: actions/setup-node@v4
16+
- name: Setup node
17+
uses: actions/setup-node@v4
1718
with:
1819
node-version: 18
1920
cache: npm

0 commit comments

Comments
 (0)