Skip to content

Update supported models #35

Update supported models

Update supported models #35

# Generates a shareable Fern preview URL for every docs PR and posts it as a comment.
# Requires the FERN_TOKEN repository secret.
name: Fern Docs Preview
on:
push:
branches:
- "pull-request/[0-9]+"
env:
PREVIEW_PATHS: |
docs/**
fern/**
package.json
.github/workflows/*fern*.yml
.github/workflows/*fern*.yaml
jobs:
preview:
name: Generate preview
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v7
- name: Check docs-related changes vs main
id: changes
shell: bash
run: |
git fetch origin main
mapfile -t paths <<< "$PREVIEW_PATHS"
pathspecs=()
for path in "${paths[@]}"; do
[[ -z "$path" ]] && continue
pathspecs+=(":(glob)$path")
done
if git diff --quiet origin/main...HEAD -- "${pathspecs[@]}"; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-node@v6
if: steps.changes.outputs.changed == 'true'
- name: Install dependencies
if: steps.changes.outputs.changed == 'true'
run: npm install
- name: Generate preview
id: preview
if: steps.changes.outputs.changed == 'true'
run: |
output=$(npm run docs:preview 2>&1)
echo "$output"
url=$(printf '%s\n' "$output" \
| grep -oP 'https://[A-Za-z0-9./?&=_:%#~+-]*buildwithfern\.com[A-Za-z0-9./?&=_:%#~+-]*' \
| tail -n 1 \
| perl -CS -pe 's/\x{200B}//g; s/%E2%80%8B$//i')
echo "url=$url" >> "$GITHUB_OUTPUT"
env:
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
- name: Post preview URL
if: steps.changes.outputs.changed == 'true' && steps.preview.outputs.url != ''
uses: actions/github-script@v9
with:
script: |
const match = context.ref.match(/^refs\/heads\/pull-request\/([0-9]+)$/)
if (!match) {
core.setFailed(`Could not find PR number from ref: ${context.ref}`)
return
}
await github.rest.issues.createComment({
issue_number: Number(match[1]),
owner: context.repo.owner,
repo: context.repo.repo,
body: '📖 [**Docs preview**](${{ steps.preview.outputs.url }})'
})