Skip to content

Commit 26eb13f

Browse files
authored
Merge pull request #9 from JavaZeroo/codex/add-pr-preview-page-with-github-action
Add PR preview deployment workflow
2 parents 42284e4 + 02d2f5b commit 26eb13f

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ jobs:
1010
build-and-deploy:
1111
runs-on: ubuntu-latest
1212
permissions:
13-
contents: read
14-
pages: write
15-
id-token: write
13+
contents: write
1614

1715
steps:
1816
- name: Checkout
@@ -39,14 +37,10 @@ jobs:
3937
- name: Build
4038
run: npm run build
4139

42-
- name: Setup Pages
43-
uses: actions/configure-pages@v4
44-
45-
- name: Upload artifact
46-
uses: actions/upload-pages-artifact@v3
47-
with:
48-
path: './dist'
49-
5040
- name: Deploy to GitHub Pages
51-
id: deployment
52-
uses: actions/deploy-pages@v4
41+
uses: JamesIves/github-pages-deploy-action@v4
42+
with:
43+
folder: ./dist
44+
branch: gh-pages
45+
clean-exclude: pr-preview
46+
force: false

.github/workflows/pr-preview.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy PR Preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, closed]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
deploy-preview:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install and Build
25+
if: github.event.action != 'closed'
26+
run: |
27+
npm install
28+
npm run build
29+
30+
- name: Deploy preview
31+
uses: rossjrw/pr-preview-action@v1
32+
with:
33+
source-dir: ./dist/
34+
pages-base-url: log.javazero.top
35+
preview-branch: gh-pages
36+

0 commit comments

Comments
 (0)