diff --git a/.github/workflows/preview-docs.yml b/.github/workflows/preview-docs.yml new file mode 100644 index 0000000..465b4ff --- /dev/null +++ b/.github/workflows/preview-docs.yml @@ -0,0 +1,42 @@ +name: Preview docs + +on: + pull_request: + workflow_dispatch: + +jobs: + preview: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - name: Check out repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 + + - name: Set up Fern CLI + uses: fern-api/setup-fern-cli@d07601425e9c9ede8745d71ca75c4c462d98755d #v1 + + - name: Generate preview URL + id: generate-docs + env: + FERN_TOKEN: ${{ secrets.FERN_TOKEN }} + run: | + OUTPUT=$(fern generate --docs --preview 2>&1) || true + echo "$OUTPUT" + URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()') + if [ -z "$URL" ]; then + echo "preview_url=" >> "$GITHUB_OUTPUT" + echo "⚠️ Failed to generate docs preview. Check the workflow logs for details." > preview_url.txt + else + echo "preview_url=$URL" >> "$GITHUB_OUTPUT" + echo "🌿 Preview your docs: $URL" > preview_url.txt + fi + + - name: Comment URL in PR + if: github.event_name == 'pull_request' + uses: thollander/actions-comment-pull-request@1d3973dc4b8e1399c0620d3f2b1aa5e795465308 #v2.4.3 + with: + filePath: preview_url.txt + comment_tag: preview-docs + mode: upsert diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml new file mode 100644 index 0000000..fbf55a2 --- /dev/null +++ b/.github/workflows/publish-docs.yml @@ -0,0 +1,24 @@ +name: Publish docs + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Check out repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 + + - name: Set up Fern CLI + uses: fern-api/setup-fern-cli@d07601425e9c9ede8745d71ca75c4c462d98755d #v1 + + - name: Publish docs + env: + FERN_TOKEN: ${{ secrets.FERN_TOKEN }} + run: fern generate --docs --log-level debug diff --git a/.gitignore b/.gitignore index f67c938..f6da19c 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,7 @@ pids # Temporary folders tmp/ -temp/ \ No newline at end of file +temp/ + +# Local files +*.local.json \ No newline at end of file