959a391334
Some checks failed
publish docs / publish-docs (push) Has been cancelled
release-please / release-please (push) Has been cancelled
tests / setup (push) Has been cancelled
tests / ${{ matrix.quality-command }} (black) (push) Has been cancelled
tests / ${{ matrix.quality-command }} (mypy) (push) Has been cancelled
tests / ${{ matrix.quality-command }} (ruff) (push) Has been cancelled
tests / test (push) Has been cancelled
tests / all_checks_passed (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
55 lines
1.5 KiB
YAML
55 lines
1.5 KiB
YAML
name: deploy preview docs
|
|
|
|
on:
|
|
pull_request_target:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "fern/**"
|
|
|
|
jobs:
|
|
preview-docs:
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: refs/pull/${{ github.event.pull_request.number }}/merge
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "18"
|
|
|
|
- name: Install Fern
|
|
run: npm install -g fern-api
|
|
|
|
- name: Generate Documentation Preview with Fern
|
|
id: generate_docs
|
|
env:
|
|
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
|
|
run: |
|
|
output=$(fern generate --docs --preview --log-level debug)
|
|
echo "$output"
|
|
# Extract the URL
|
|
preview_url=$(echo "$output" | grep -oP '(?<=Published docs to )https://[^\s]*')
|
|
# Set the output for the step
|
|
echo "::set-output name=preview_url::$preview_url"
|
|
- name: Comment PR with URL using github-actions bot
|
|
uses: actions/github-script@v7
|
|
if: ${{ steps.generate_docs.outputs.preview_url }}
|
|
with:
|
|
script: |
|
|
const preview_url = '${{ steps.generate_docs.outputs.preview_url }}';
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: `Published docs preview URL: ${preview_url}`
|
|
})
|