Merge pull request #69 from thenorthsolution/main-cf-autofix #1025
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: Generate Docs | |
on: | |
push: | |
branches: ['main'] | |
tags: ['**'] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build documentation | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'thenorthsolution' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name || '' }} | |
- name: Install node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: 'npm' | |
cache-dependency-path: package-lock.json | |
- name: Install dependencies | |
run: npm install | |
- name: Build Docgen | |
run: npm run build -w @reciple/utils -w @reciple/docgen | |
- name: Build docs.json | |
run: npm run docs | |
- name: Upload docgen artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docgen | |
path: packages/*/docs/docs.json | |
upload: | |
name: Upload Documentation | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 1 | |
fail-fast: false | |
matrix: | |
package: ['core', 'reciple', 'decorators', 'message-command-utils', 'utils', 'docgen', 'create-reciple'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name || '' }} | |
- name: Install node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: 'npm' | |
cache-dependency-path: package-lock.json | |
- name: Download docgen artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: docgen | |
path: docs | |
- name: Install dependencies | |
run: npm install | |
- name: Format tag package semver | |
id: format-tag | |
if: ${{ github.ref_type == 'tag' }} | |
uses: ./packages/actions/src/formatTag | |
with: | |
tag: ${{ github.ref_name }} | |
- name: Checkout docs repository | |
uses: actions/checkout@v4 | |
with: | |
ref: 'tags' | |
path: 'out' | |
- name: Move docs to correct directory (Tag) | |
if: ${{ github.ref_type == 'tag' && matrix.package == steps.format-tag.outputs.package }} | |
env: | |
PACKAGE: ${{ steps.format-tag.outputs.package }} | |
SEMVER: ${{ steps.format-tag.outputs.semver }} | |
run: | | |
echo "docs/${PACKAGE}/docs/docs.json > out/${PACKAGE}/${SEMVER}.json" | |
mkdir -p out/${PACKAGE} | |
mv docs/${PACKAGE}/docs/docs.json out/${PACKAGE}/${SEMVER}.json | |
- name: Move docs to correct directory (Branch) | |
if: ${{ github.ref_type == 'branch' }} | |
env: | |
PACKAGE: ${{ matrix.package }} | |
run: | | |
echo "docs/${PACKAGE}/docs/docs.json > out/${PACKAGE}/${GITHUB_REF_NAME}.json" | |
mkdir -p out/${PACKAGE} | |
mv docs/${PACKAGE}/docs/docs.json out/${PACKAGE}/${GITHUB_REF_NAME}.json | |
- name: Commit and push | |
run: | | |
cd out | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git pull | |
git add . | |
git commit -m "Docs build for ${GITHUB_REF_TYPE} ${GITHUB_REF_NAME}: ${GITHUB_SHA}" || true | |
git pull | |
git push |