refactor(ci): streamline documentation build workflow by removing deb… #45
This file contains hidden or 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: Documentation Build and Deploy CI | |
| on: | |
| # # Wait for Compilation Tests workflow to complete (uses macOS binaries) | |
| # workflow_run: | |
| # workflows: ["Compilation Tests"] | |
| # types: | |
| # - completed | |
| # branches: | |
| # - master | |
| # - release/v2.x | |
| # - wokwi-embed-launchpad | |
| # Manual trigger for testing docs changes without waiting for compilation | |
| workflow_dispatch: | |
| # Also run on direct pushes to docs or workflow files (for testing) | |
| push: | |
| branches: | |
| - master | |
| - release/v2.x | |
| - wokwi-embed-launchpad | |
| paths: | |
| - "docs/**" | |
| - ".github/workflows/docs_build.yml" | |
| pull_request: | |
| paths: | |
| - "docs/**" | |
| - ".github/workflows/docs_build.yml" | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-docs: | |
| name: Build ESP-Docs | |
| runs-on: ubuntu-22.04 | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| submodules: true | |
| - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.0.4 | |
| with: | |
| cache-dependency-path: docs/requirements.txt | |
| cache: "pip" | |
| python-version: "3.10" | |
| - name: Restore docs binaries from cache (macOS builds) | |
| id: cache-restore | |
| uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| key: docs-binaries-macos-${{ github.run_id }} | |
| restore-keys: | | |
| docs-binaries-macos- | |
| path: docs_binaries | |
| lookup-only: false | |
| - name: Copy cached binaries to docs/_static/binaries/ | |
| run: | | |
| mkdir -p docs/_static/binaries | |
| if [ ! -d "docs_binaries" ]; then | |
| echo "WARNING: No docs_binaries directory found, continuing without binaries." | |
| exit 0 | |
| fi | |
| bin_count=0 | |
| while IFS= read -r bin_file; do | |
| bin_name=$(basename "$bin_file") | |
| sketch_name="${bin_name%.ino.merged.bin}" | |
| if [[ "$bin_file" =~ /(esp32[a-z0-9]*)/ ]]; then | |
| target="${BASH_REMATCH[1]}" | |
| else | |
| continue | |
| fi | |
| sketch_ino_file=$(find libraries -type f -name "${sketch_name}.ino" 2>/dev/null | head -1) | |
| if [ -z "$sketch_ino_file" ]; then | |
| continue | |
| fi | |
| sketch_dir=$(dirname "$sketch_ino_file") | |
| relative_path="${sketch_dir#libraries/}" | |
| output_dir="docs/_static/binaries/libraries/${relative_path}/${target}" | |
| mkdir -p "$output_dir" | |
| cp "$bin_file" "$output_dir/" | |
| bin_count=$((bin_count + 1)) | |
| ci_json_file=$(dirname "$bin_file")/ci.json | |
| if [ -f "$ci_json_file" ]; then | |
| cp "$ci_json_file" "$output_dir/" | |
| fi | |
| done < <(find docs_binaries -type f -name "*.merged.bin") | |
| - name: Cleanup Binaries | |
| run: | | |
| python3 .github/scripts/docs_build_examples.py -c | |
| - name: Show processed projects | |
| run: | | |
| echo "Projects ready for documentation:" | |
| find docs/_static/binaries/libraries -type f -name "*.ino.merged.bin" 2>/dev/null | while read f; do | |
| basename "$f" .ino.merged.bin | |
| done | sort -u | |
| - name: Build | |
| run: | | |
| sudo apt update | |
| sudo apt install python3-pip python3-setuptools | |
| # GitHub CI installs pip3 and setuptools outside the path. | |
| # Update the path to include them and run. | |
| cd ./docs | |
| PATH=/home/runner/.local/bin:$PATH pip3 install -r requirements.txt --prefer-binary | |
| PATH=/home/runner/.local/bin:$PATH SPHINXOPTS="-W" build-docs -l en | |
| - name: Archive Docs | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: docs | |
| path: docs |