Skip to content

Commit 5adf0dc

Browse files
Copilothawkeyexl
andcommitted
Add Fern docs workflows for PR preview and publish on main
Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
1 parent ce60e5f commit 5adf0dc

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

.github/workflows/preview-docs.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Preview docs
2+
3+
on: pull_request
4+
5+
jobs:
6+
preview:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
steps:
12+
- name: Check out repository
13+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
14+
15+
- name: Set up Fern CLI
16+
uses: fern-api/setup-fern-cli@d07601425e9c9ede8745d71ca75c4c462d98755d #v1
17+
18+
- name: Generate preview URL
19+
id: generate-docs
20+
env:
21+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
22+
run: |
23+
OUTPUT=$(fern generate --docs --preview 2>&1) || true
24+
echo "$OUTPUT"
25+
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
26+
if [ -z "$URL" ]; then
27+
echo "preview_url=" >> "$GITHUB_OUTPUT"
28+
echo "⚠️ Failed to generate docs preview. Check the workflow logs for details." > preview_url.txt
29+
else
30+
echo "preview_url=$URL" >> "$GITHUB_OUTPUT"
31+
echo "🌿 Preview your docs: $URL" > preview_url.txt
32+
fi
33+
34+
- name: Comment URL in PR
35+
uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 #v2.4.3
36+
with:
37+
filePath: preview_url.txt
38+
comment_tag: preview-docs
39+
mode: upsert

.github/workflows/publish-docs.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
if: github.run_number > 1
12+
permissions:
13+
contents: read
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
17+
18+
- name: Set up Fern CLI
19+
uses: fern-api/setup-fern-cli@d07601425e9c9ede8745d71ca75c4c462d98755d #v1
20+
21+
- name: Publish docs
22+
env:
23+
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
24+
run: fern generate --docs --log-level debug

0 commit comments

Comments
 (0)