Fern Docs Generation #429
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Fern Docs Generation | |
on: | |
push: | |
branches: [main] | |
paths: | |
- "backend/airweave/api/**/*.py" | |
- "frontend/src/components/icons/apps/**" | |
- "backend/airweave/platform/entities/**" | |
- "backend/airweave/platform/sources/**" | |
- "backend/airweave/platform/configs/auth.py" | |
- "fern/**" | |
- ".github/workflows/fern-docs.yml" | |
workflow_dispatch: | |
jobs: | |
generate-docs: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
- name: Install Python dependencies | |
working-directory: ./backend | |
run: poetry install | |
- name: Install documentation dependencies | |
run: pip install pyyaml | |
- name: Generate connector documentation | |
run: python fern/scripts/update_connector_docs.py | |
- name: Generate OpenAPI spec | |
working-directory: ./backend | |
run: poetry run python ${{ github.workspace }}/fern/scripts/generate_openapi.py | |
env: | |
FIRST_SUPERUSER: "[email protected]" | |
FIRST_SUPERUSER_PASSWORD: "docs-password" | |
ENCRYPTION_KEY: "docs-encryption-key" | |
POSTGRES_HOST: "localhost" | |
POSTGRES_USER: "postgres" | |
POSTGRES_PASSWORD: "postgres" | |
OPENAI_API_KEY: "sk-docs" | |
LOCAL_DEVELOPMENT: "true" | |
STATE_SECRET: "dummy-state-secret-key-1234567890-abcdefghijklmn" | |
- name: Verify OpenAPI spec generation | |
run: | | |
if [ ! -f "fern/definition/openapi.json" ]; then | |
echo "❌ Error: OpenAPI spec was not generated at fern/definition/openapi.json" | |
exit 1 | |
fi | |
echo "✅ OpenAPI spec generated successfully" | |
echo "File size: $(wc -c < fern/definition/openapi.json) bytes" | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: Install Fern | |
run: npm install -g fern-api | |
- name: Generate Docs | |
run: | | |
cd fern | |
fern generate --docs | |
env: | |
FERN_TOKEN: ${{ secrets.FERN_TOKEN }} | |
- name: Verify Fern docs generation | |
run: | | |
if [ ! -d "fern/docs" ]; then | |
echo "❌ Error: Fern docs directory was not created" | |
exit 1 | |
fi | |
echo "✅ Fern docs generated successfully" | |
echo "Generated files:" | |
find fern/docs -name "*.md" -o -name "*.mdx" | head -10 | |
- name: Commit changes | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
# Add all generated documentation files | |
git add fern/definition/openapi.json || echo "No openapi.json changes to add" | |
git add fern/docs/pages/connectors/ || echo "No connector docs changes to add" | |
git add fern/docs.yml || echo "No docs.yml changes to add" | |
# Check if there are any changes to commit | |
if git diff --staged --quiet; then | |
echo "✅ No documentation changes to commit" | |
else | |
echo "📝 Committing documentation updates..." | |
git commit -m "docs: update documentation [skip ci]" | |
git push | |
echo "✅ Documentation changes committed and pushed" | |
fi |