Skip to content

Commit ee5c6f8

Browse files
committed
fix: split preview and deploy workflows
1 parent a73aac5 commit ee5c6f8

File tree

2 files changed

+55
-47
lines changed

2 files changed

+55
-47
lines changed

.github/workflows/deployment.yaml

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ on:
44
push:
55
branches:
66
- master
7-
pull_request:
8-
types: [ opened, synchronize, reopened ]
9-
branches:
10-
- master
11-
12-
concurrency: preview-${{ github.ref }}
137

148
jobs:
159
build:
@@ -50,7 +44,6 @@ jobs:
5044
deploy:
5145
name: Deploy to GitHub Pages
5246
needs: build
53-
if: github.event_name == 'push'
5447

5548
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
5649
permissions:
@@ -66,43 +59,4 @@ jobs:
6659
steps:
6760
- name: Deploy to GitHub Pages
6861
id: deployment
69-
uses: actions/deploy-pages@v4
70-
71-
deploy-preview:
72-
name: "Deploy Preview for PR #${{github.event.pull_request.number}}"
73-
if: github.event_name == 'pull_request' # Only run for pull requests
74-
runs-on: ubuntu-latest
75-
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
76-
permissions:
77-
pages: write # to deploy to Pages
78-
pull-requests: write
79-
contents: write
80-
id-token: write
81-
82-
env:
83-
DOCASAURUS_BASE_URL: https://chargepi.cc/pr-preview-action/pr-${{github.event.pull_request.number}}
84-
85-
steps:
86-
- name: Checkout
87-
uses: actions/checkout@v4
88-
89-
- uses: actions/setup-node@v4
90-
with:
91-
node-version: latest
92-
# cache: yarn
93-
94-
- uses: pnpm/action-setup@v4
95-
with:
96-
version: 10.11.0
97-
98-
- name: Install and Build
99-
run: |
100-
pnpm install
101-
pnpm run build
102-
103-
- name: Deploy preview
104-
uses: rossjrw/pr-preview-action@v1
105-
with:
106-
source-dir: ./build/
107-
action: 'auto'
108-
pages-base-url: chargepi.cc
62+
uses: actions/deploy-pages@v4

.github/workflows/preview.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: preview.yaml
2+
on:
3+
pull_request:
4+
types: [ opened, synchronize, reopened ]
5+
branches:
6+
- master
7+
8+
concurrency: preview-${{ github.ref }}
9+
10+
jobs:
11+
deploy-preview:
12+
name: "Deploy Preview for PR #${{github.event.pull_request.number}}"
13+
if: github.event_name == 'pull_request' # Only run for pull requests
14+
runs-on: ubuntu-latest
15+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
16+
permissions:
17+
pages: write # to deploy to Pages
18+
pull-requests: write
19+
contents: write
20+
id-token: write
21+
22+
env:
23+
DOCASAURUS_BASE_URL: https://chargepi.cc/pr-preview-action/pr-${{github.event.pull_request.number}}
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: latest
32+
# cache: yarn
33+
34+
- uses: pnpm/action-setup@v4
35+
with:
36+
version: 10.11.0
37+
38+
- name: Install and Build
39+
run: |
40+
pnpm install
41+
pnpm run build
42+
43+
- name: Deploy 🚀
44+
uses: JamesIves/github-pages-deploy-action@v4
45+
with:
46+
folder: build # The folder the action should deploy.
47+
target-folder: ${{ github.ref_name }}/build
48+
49+
- name: Deploy preview
50+
uses: rossjrw/pr-preview-action@v1
51+
with:
52+
source-dir: ${{ github.ref_name }}/build
53+
action: 'auto'
54+
pages-base-url: chargepi.cc

0 commit comments

Comments
 (0)