Build & Publish docs #71
This file contains 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: Build & Publish docs | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build & Publish docs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Build Docusaurus | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
cache: "npm" | |
cache-dependency-path: "docs/package-lock.json" | |
- name: Cache docusaurus | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ github.workspace }}/docs/.docusaurus | |
key: | | |
${{ runner.os }}-docusaurus | |
restore-keys: | | |
${{ runner.os }}-docusaurus | |
- name: Install dependencies | |
run: | | |
npm ci --prefix docs | |
- name: Lint / Formatting | |
run: | | |
npm run typecheck --prefix docs | |
# TODO: should add more in the future if needed | |
- name: Build | |
run: | | |
npm run build --prefix docs | |
# Fetch API documentation | |
- uses: aica-technology/.github/.github/actions/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: aica-technology/.github/.github/actions/[email protected] | |
id: ensure-image | |
with: | |
image_name: aica-technology/backend-api-docs | |
- name: Get API version to fetch | |
id: api-version | |
run: | | |
VER="$(cat docs/api.version)" | |
echo "Version: $VER" | |
echo "version=$VER" >> $GITHUB_OUTPUT | |
- name: Create directory | |
run: | | |
mkdir -p docs/build/api | |
- name: Extract Swagger from the built image | |
uses: aica-technology/.github/.github/actions/[email protected] | |
with: | |
image: ${{ steps.ensure-image.outputs.image_name }}:${{ steps.api-version.outputs.version }} | |
source: /index.html | |
destination: docs/build/api/index.html | |
# Deploy to GitHub Pages | |
- name: Deploy | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref_name == 'main') | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: docs/build |