Skip to content

Commit 0102da9

Browse files
committed
setup preview and publish docs
1 parent 14b8dad commit 0102da9

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.github/workflows/preview-docs.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Preview Docs
2+
3+
on: pull_request
4+
5+
jobs:
6+
run:
7+
runs-on: ubuntu-latest
8+
permissions: write-all
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
12+
13+
- name: Install Fern
14+
run: npm install -g fern-api
15+
16+
- name: Generate preview URL
17+
id: generate-docs
18+
env:
19+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
20+
run: |
21+
OUTPUT=$(fern generate --docs --preview 2>&1) || true
22+
echo "$OUTPUT"
23+
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
24+
echo "Preview URL: $URL"
25+
echo "🌿 Preview your docs: $URL" > preview_url.txt
26+
27+
- name: Comment URL in PR
28+
uses: thollander/[email protected]
29+
with:
30+
filePath: preview_url.txt

.github/workflows/publish-docs.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
run:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/heads/main') && github.run_number > 1 }}
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Install Fern
17+
run: npm install -g fern-api
18+
19+
- name: Publish Docs
20+
env:
21+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
22+
run: fern generate --docs

0 commit comments

Comments
 (0)