Skip to content

Generate API Documentation #27

Generate API Documentation

Generate API Documentation #27

Workflow file for this run

name: Generate API Documentation
on:
pull_request:
branches:
- main
types:
- closed # Trigger after a PR into main is closed
paths:
- 'res/**' # This will only trigger on changes to the /res/ folder
workflow_dispatch:
jobs:
generate-docs:
runs-on: ubuntu-latest
permissions:
contents: write # Add permissions for writing content (creating releases)
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install pyyaml
pip install pytest
- name: Run tests
working-directory: redocly
run: pytest ./scripts/combine_yamls_test.py
- name: Run Python script to combine YAMLs
working-directory: redocly # Run script in the redocly folder
run: |
mkdir -p output
python ./scripts/combine_yamls.py
- name: Install Redocly CLI
run: npm install -g @redocly/cli
- name: Generate API documentation with Redocly
working-directory: redocly # Run Redocly CLI in the redocly folder
run: |
redocly build-docs ./master_api_combined.yaml --template templates/redoc-template.html --output output/api-reference.htm
- name: Remove HTML comments
# Run the Python script to remove comments and extra whitespace so Madcap Flare displays it nicely.
working-directory: redocly
run: python ./scripts/remove_comments.py
- name: Create tar.gz of HTML file
run: |
tar -czf redoc-static-${{ github.head_ref || github.ref_name }}.tar.gz -C redocly/output api-reference.htm
- name: Create release
id: create-release
uses: ncipollo/release-action@v1
with:
tag: api-ref-${{ github.head_ref || github.ref_name }}
name: "API Documentation - ${{ github.head_ref || github.ref_name }}"
artifacts: redoc-static-${{ github.head_ref || github.ref_name }}.tar.gz
omitBody: true