Files
coopenomics/.github/workflows/publish-docs.yaml
T
Alex Ant 519f34eecb update
2026-03-20 19:18:34 +05:00

144 lines
4.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Publish Coopenomics Website
on:
push:
branches:
- master
repository_dispatch:
types: [deploy_from_mono]
jobs:
build-and-publish-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Clone mono repository
run: |
git clone https://github.com/coopenomics/mono.git mono-repo
cd mono-repo
git checkout capital
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Doxygen 1.9.3
run: |
curl -L "https://sourceforge.net/projects/doxygen/files/rel-1.9.3/doxygen-1.9.3.linux.bin.tar.gz/download" -o doxygen.tar.gz
tar xzf doxygen.tar.gz
sudo cp doxygen-1.9.3/bin/doxygen /usr/local/bin/
doxygen --version
- name: Install pnpm
run: npm install -g pnpm
- name: Install redocly
run: npm install -g @redocly/cli
- name: Install Python requirements
run: |
python -m venv venv
source venv/bin/activate
pip install mkdocs-material mkdocs-macros-plugin mkdocs-section-index pymdown-extensions
- name: Install Node.js dependencies
run: pnpm install
- name: Generate contracts documentation with Doxygen
run: |
cd mono-repo/components/contracts
doxygen
- name: Generate cooptypes docs
run: |
cd mono-repo/components/cooptypes
pnpm install
pnpm run build
pnpm run docs
- name: Generate SDK documentation
run: |
cd mono-repo/components/sdk
pnpm install
pnpm run build
pnpm run docs
- name: Generate Chain API documentation
run: |
mkdir -p docs/api/chain
redocly build-docs coopos/chain.swagger.yaml --output docs/api/chain/index.html
- name: Generate DB Size API documentation
run: |
mkdir -p docs/api/db_size
redocly build-docs coopos/db_size.swagger.yaml --output docs/api/db_size/index.html
- name: Generate Net API documentation
run: |
mkdir -p docs/api/net
redocly build-docs coopos/net.swagger.yaml --output docs/api/net/index.html
- name: Generate Trace API documentation
run: |
mkdir -p docs/api/trace
redocly build-docs coopos/trace_api.swagger.yaml --output docs/api/trace/index.html
- name: Generate Producer API documentation
run: |
mkdir -p docs/api/producer
redocly build-docs coopos/producer.swagger.yaml --output docs/api/producer/index.html
# Redocly вшивает redoc.standalone.js с cdn.redocly.com — из РФ/части сетей CDN таймаутит.
# Кладём тот же артефакт рядом со страницами и подменяем src на относительный путь.
- name: Self-host Redoc bundle (replace CDN)
run: |
set -e
VER=$(grep -hoE 'cdn\.redocly\.com/redoc/[^/]+' docs/api/*/index.html 2>/dev/null | head -1 | sed 's|.*/||')
if [ -z "$VER" ]; then
if ls docs/api/*/index.html >/dev/null 2>&1; then
echo "ERROR: есть docs/api/*/index.html, но не найден cdn.redocly.com — формат вывода Redocly сменился."
exit 1
fi
exit 0
fi
curl -fsSL "https://cdn.jsdelivr.net/npm/redoc@${VER}/bundles/redoc.standalone.js" -o docs/api/redoc.standalone.js
for f in docs/api/*/index.html; do
sed -i 's|https://cdn\.redocly\.com/redoc/[^/]*/bundles/redoc\.standalone\.js|../redoc.standalone.js|g' "$f"
done
- name: Copy contracts documentation
run: |
mkdir -p docs/contracts
cp -r mono-repo/components/contracts/docs/html/* docs/contracts/
- name: Copy SDK documentation
run: |
mkdir -p docs/sdk
rsync -av --exclude='typedoc.json' mono-repo/components/sdk/docs/ docs/sdk/
- name: Copy cooptypes documentation
run: |
mkdir -p docs/cooptypes
cp -r mono-repo/components/cooptypes/docs/* docs/cooptypes/
- name: Build docs (mkdocs)
run: |
source venv/bin/activate
mkdocs build
- name: Publish to GitHub Pages
run: npx gh-pages --nojekyll -d site --repo https://x-access-token:${GITHUB_TOKEN}@github.com/coopenomics/coopenomics.git
env:
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: github-actions@github.com
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: github-actions@github.com
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}