Skip to content

Commit 2f6ca9b

Browse files
authored
Merge pull request #4 from doc-detective/copilot/add-workflows-for-docs-preview
Add Fern docs workflows for PR preview and publish on main
2 parents 87f5e9a + ac16fc7 commit 2f6ca9b

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

.github/workflows/preview-docs.yml

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

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ pids
4545

4646
# Temporary folders
4747
tmp/
48-
temp/
48+
temp/
49+
50+
# Local files
51+
*.local.json

0 commit comments

Comments
 (0)