Skip to content

Commit

Permalink
Create preview-docs.yml (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannysheridan authored Nov 8, 2023
1 parent 31bedf9 commit 3559b6b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ci

on:
pull_request:
branches:
- main

jobs:
preview-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- 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)
echo "$output"
# Extract the URL and append it to GITHUB_ENV
echo "preview_url=$(echo "$output" | grep -oP '(?<=Published docs to )https://[^\s]*')" >> $GITHUB_ENV
- name: Comment PR with URL using github-actions bot
uses: actions/github-script@v4
if: ${{ steps.generate_docs.outputs.preview_url }}
with:
script: |
const preview_url = '${{ env.preview_url }}';
const issue_number = context.issue.number;
github.issues.createComment({
...context.repo,
issue_number: issue_number,
body: `Published docs preview URL: ${preview_url}`
})
2 changes: 1 addition & 1 deletion fern/fern.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"organization": "YourOrganization",
"organization": "your-organization",
"version": "0.15.0-rc50"
}
2 changes: 1 addition & 1 deletion fern/generators.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}

0 comments on commit 3559b6b

Please sign in to comment.