2023-04-03 19:30:50 +08:00
|
|
|
name: Build documentation
|
2022-09-09 11:52:06 +08:00
|
|
|
|
|
|
|
on:
|
2023-10-08 14:39:57 +08:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- refactor-structure
|
2022-09-10 08:18:35 +08:00
|
|
|
pull_request:
|
|
|
|
workflow_call:
|
2023-03-25 13:22:48 +08:00
|
|
|
inputs:
|
|
|
|
ref:
|
|
|
|
description: 'commit to build'
|
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
path:
|
|
|
|
description: 'path within the docs pages to build to'
|
|
|
|
type: string
|
|
|
|
required: false
|
|
|
|
artifact:
|
|
|
|
description: 'artifact name to write'
|
|
|
|
type: string
|
|
|
|
required: false
|
2023-07-30 11:28:18 +08:00
|
|
|
latest:
|
|
|
|
description: 'build the latest release'
|
|
|
|
type: boolean
|
|
|
|
required: false
|
2022-09-09 11:52:06 +08:00
|
|
|
|
|
|
|
jobs:
|
2022-09-10 08:18:35 +08:00
|
|
|
build-docs:
|
|
|
|
name: Build documentation
|
2022-09-09 11:52:06 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-11-01 18:01:18 +08:00
|
|
|
- uses: actions/setup-node@v4
|
2022-09-09 11:52:06 +08:00
|
|
|
with:
|
|
|
|
node-version: 18
|
2023-07-30 11:28:18 +08:00
|
|
|
|
2023-09-13 22:47:46 +08:00
|
|
|
- uses: actions/checkout@v4
|
2023-03-25 13:22:48 +08:00
|
|
|
with:
|
2023-07-30 11:28:18 +08:00
|
|
|
ref: ${{ inputs.ref || github.ref }}
|
2023-09-13 22:47:46 +08:00
|
|
|
- uses: actions/checkout@v4
|
2022-10-23 03:42:02 +08:00
|
|
|
with:
|
|
|
|
repository: bdunderscore/modular-avatar-images
|
|
|
|
path: modular-avatar-images
|
|
|
|
- name: Install logo assets
|
|
|
|
run: |
|
2023-10-08 14:39:57 +08:00
|
|
|
cp -Rv modular-avatar-images/img/* docs~/static/img
|
2023-02-17 20:03:57 +08:00
|
|
|
|
|
|
|
- name: Setup yarn 2.0
|
|
|
|
run: |
|
|
|
|
corepack enable
|
|
|
|
corepack prepare yarn@stable --activate
|
|
|
|
|
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
2023-10-08 14:39:57 +08:00
|
|
|
run: echo "dir=$(cd docs~; yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
2023-02-17 20:03:57 +08:00
|
|
|
|
2024-01-28 19:13:49 +08:00
|
|
|
- uses: actions/cache@v4
|
2023-02-17 20:03:57 +08:00
|
|
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
2023-10-11 19:03:26 +08:00
|
|
|
key: ${{ runner.os }}-yarn-docs-${{ hashFiles('**/yarn.lock') }}
|
2023-02-17 20:03:57 +08:00
|
|
|
restore-keys: |
|
2023-10-11 19:03:26 +08:00
|
|
|
${{ runner.os }}-yarn-docs-
|
2023-02-17 20:03:57 +08:00
|
|
|
|
2023-03-25 13:22:48 +08:00
|
|
|
- name: Set baseUri
|
2024-07-29 11:40:50 +08:00
|
|
|
if: ${{ inputs.path }}
|
2023-03-25 13:22:48 +08:00
|
|
|
run: |
|
2023-10-08 14:39:57 +08:00
|
|
|
BASEURL="/${{ inputs.path }}/" perl -i -p -e "s{baseUrl: '/'}{baseUrl: '\$ENV{BASEURL}'}" docs~/docusaurus.config.js
|
|
|
|
cat docs~/docusaurus.config.js
|
2022-09-09 11:52:06 +08:00
|
|
|
|
|
|
|
- name: Build docs
|
|
|
|
run: |
|
2023-10-08 14:39:57 +08:00
|
|
|
cd docs~
|
2023-02-17 20:03:57 +08:00
|
|
|
yarn install --immutable
|
2022-09-10 08:24:37 +08:00
|
|
|
yarn build
|
2023-03-25 13:22:48 +08:00
|
|
|
ls -lR build
|
2022-09-10 08:18:35 +08:00
|
|
|
|
2023-03-25 14:12:20 +08:00
|
|
|
- name: Set robots.txt
|
|
|
|
run: |
|
2023-10-08 14:39:57 +08:00
|
|
|
if [ -e docs~/robots.txt ]; then
|
|
|
|
cp docs~/robots.txt docs~/build/robots.txt
|
2023-03-25 14:12:20 +08:00
|
|
|
fi
|
2023-10-08 15:23:16 +08:00
|
|
|
|
|
|
|
- name: Package documentation
|
|
|
|
run: |
|
|
|
|
tar -cf docs.tar -C docs~/build .
|
2023-03-25 14:12:20 +08:00
|
|
|
|
2022-09-10 08:18:35 +08:00
|
|
|
- name: Upload artifact
|
2023-12-20 19:41:38 +08:00
|
|
|
uses: actions/upload-artifact@v4
|
2022-09-10 08:18:35 +08:00
|
|
|
with:
|
2023-03-25 13:22:48 +08:00
|
|
|
name: ${{ inputs.artifact || 'docs' }}
|
2023-10-08 15:23:16 +08:00
|
|
|
path: docs.tar
|