Deploy GitHub Pages (docs + recovery) #3
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: Deploy GitHub Pages (docs + recovery) | |
| on: | |
| push: | |
| branches: ["master"] | |
| paths: | |
| - "docs/**" | |
| - "mkdocs.yaml" | |
| - "mkdocs.yml" | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: ["Build ESP32 recovery artifacts"] | |
| types: [completed] | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| actions: read # needed to download artifacts from the triggering run | |
| concurrency: | |
| group: github-pages | |
| cancel-in-progress: true | |
| jobs: | |
| deploy: | |
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # Build docs | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install MkDocs + plugins | |
| run: | | |
| python -m pip install --upgrade pip | |
| if [ -f docs/requirements.txt ]; then | |
| pip install -r docs/requirements.txt | |
| else | |
| pip install mkdocs mkdocs-static-i18n mkdocs-autorefs pymdown-extensions | |
| fi | |
| - name: Build docs to publish/ | |
| run: | | |
| rm -rf publish | |
| mkdir -p publish | |
| mkdocs build -f mkdocs.yml -d publish | |
| - name: Download recovery artifacts from triggering run | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| run-id: ${{ github.event.workflow_run.id }} | |
| - name: Assemble /recovery into publish/ | |
| run: | | |
| mkdir -p publish/recovery/bin publish/recovery/manifests | |
| find artifacts -type f -path '*/bin/*' -exec cp -v {} publish/recovery/bin/ \; | |
| find artifacts -type f -path '*/manifests/*' -exec cp -v {} publish/recovery/manifests/ \; | |
| cat > publish/recovery/index.html <<'HTML' | |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width,initial-scale=1" /> | |
| <title>BSB-LAN Recovery Flasher</title> | |
| <script type="module" src="https://unpkg.com/esp-web-tools@latest/dist/web/install-button.js?module"></script> | |
| </head> | |
| <body> | |
| <h1>BSB-LAN Recovery Flasher</h1> | |
| <p>This page flashes <strong>recovery firmware</strong> only. <strong>It will erase all your EEPROM settings!</strong><br>Select your hardware: | |
| <h2>ESP32-DevKit</h2> | |
| <esp-web-install-button manifest="manifests/bsb-lan-recovery-devkit.json" baudrate="460800"></esp-web-install-button> | |
| <h2>Olimex EVB</h2> | |
| <esp-web-install-button manifest="manifests/bsb-lan-recovery-olimex-evb.json" baudrate="460800"></esp-web-install-button> | |
| <h2>Olimex POE-ISO</h2> | |
| <esp-web-install-button manifest="manifests/bsb-lan-recovery-olimex-poe-iso.json" baudrate="460800"></esp-web-install-button> | |
| </body> | |
| </html> | |
| HTML | |
| # Optional convenience redirect for your file-style URLs | |
| cat > publish/recovery.html <<'HTML' | |
| <!doctype html><meta charset="utf-8"> | |
| <meta http-equiv="refresh" content="0; url=/recovery/index.html"> | |
| <script>location.replace("/recovery/index.html");</script> | |
| <a href="/recovery/index.html">Recovery</a> | |
| HTML | |
| # Deploy to Pages | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: publish | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@v4 |