Skip to content

OpenAPI Build

Build OpenAPI YAML for use in Swagger or ReDoc documentation sites.

Inputs

INPUT TYPE REQUIRED DEFAULT DESCRIPTION
example_env_file_path string true FastAPI must start with an
environment set. Path to a
.env with dummy vars.
image string true The image to build to
OpenAPI JSON (dependencies included, i.e. FastAPI.).
output_path string false If specified, the output dir
is uploaded to the artifact
key.

Outputs

No outputs.

Secrets

No secrets.

Example Usage

name: 📖 Publish Docs

on:
  push:
    paths:
      - docs/**
      - src/**
      - mkdocs.yml
    branches: [development]
  # Allow manual trigger (workflow_dispatch)
  workflow_dispatch:

jobs:
  build_openapi_json:
    uses: hotosm/gh-workflows/.github/workflows/openapi_build.yml@1.6.0
    with:
      image: ghcr.io/${{ github.repository }}/backend:ci-${{ github.ref_name }}
      example_env_file_path: ".env.example"
      output_path: docs/openapi.json

  publish_docs:
    uses: hotosm/gh-workflows/.github/workflows/mkdocs_build.yml@1.6.0
    needs:
      - build_openapi_json
    with:
      image: ghcr.io/${{ github.repository }}/backend:ci-${{ github.ref_name }}
      openapi: true

Last update: July 27, 2024