Skip to content

Commit 9b6dd7a

Browse files
committed
fix: pr from forks deployment issue
Signed-off-by: Aritra Dey <[email protected]>
1 parent 332e137 commit 9b6dd7a

File tree

1 file changed

+59
-25
lines changed

1 file changed

+59
-25
lines changed

.github/workflows/publish-docs.yml

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,81 @@ on:
55
branches: [master]
66
pull_request:
77
branches: [master]
8-
types: [opened, synchronize, reopened, closed]
98

109
permissions:
1110
contents: write
1211
pull-requests: write
13-
statuses: write
14-
id-token: write
15-
16-
concurrency:
17-
group: "pages"
18-
cancel-in-progress: true
1912

2013
jobs:
21-
build-and-deploy:
14+
build:
2215
runs-on: ubuntu-latest
16+
2317
steps:
24-
- name: Checkout 🛎️
18+
- name: Checkout
2519
uses: actions/checkout@v4
2620

27-
- name: Setup Node.js
21+
- name: Setup Node.js
2822
uses: actions/setup-node@v4
2923
with:
30-
node-version: '20'
24+
node-version: 20
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Build
30+
run: npm run build
31+
32+
- name: Upload build artifact
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: site
36+
path: build/
37+
38+
deploy-pr-preview:
39+
# Runs ONLY for PRs
40+
if: ${{ github.event_name == 'pull_request' }}
41+
runs-on: ubuntu-latest
42+
needs: build
3143

32-
- name: Install and Build 🔧
33-
run: |
34-
npm ci
35-
npm run build
44+
steps:
45+
- name: Download build artifact
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: site
49+
path: site
3650

37-
- name: Deploy Preview deploy-preview 🚀
38-
if: github.event_name == 'pull_request'
39-
uses: rossjrw/pr-preview-action@v1
51+
- name: Deploy PR Preview
52+
uses: JamesIves/github-pages-deploy-action@v4
53+
with:
54+
branch: gh-pages-pr-previews
55+
folder: site
56+
target-folder: pr-${{ github.event.pull_request.number }}
57+
58+
- name: Comment Preview URL
59+
uses: marocchino/sticky-pull-request-comment@v2
60+
with:
61+
recreate: true
62+
message: |
63+
🚀 **Preview Ready!**
64+
Your docs preview for this PR is available here:
65+
66+
**https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/**
67+
68+
deploy-production:
69+
# Runs ONLY on push to master
70+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
71+
runs-on: ubuntu-latest
72+
needs: build
73+
74+
steps:
75+
- name: Download build artifact
76+
uses: actions/download-artifact@v4
4077
with:
41-
source-dir: ./build/
42-
preview-branch: gh-pages-pr-previews
43-
umbrella-dir: pr-preview
44-
action: auto
78+
name: site
79+
path: site
4580

46-
- name: Deploy to GitHub Pages 🚀
47-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
81+
- name: Deploy to GitHub Pages
4882
uses: JamesIves/github-pages-deploy-action@v4
4983
with:
5084
branch: gh-pages
51-
folder: build
85+
folder: site

0 commit comments

Comments
 (0)