Add GitHub Actions workflow for deployment and documentation build #9
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: Deploy | |
on: | |
# push: | |
# branches: | |
# - main | |
pull_request: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The version of the firmware to build" | |
required: true | |
type: string | |
release-url: | |
description: "Release URL" | |
required: true | |
type: string | |
jobs: | |
build-firmware: | |
name: Build Firmware | |
uses: esphome/workflows/.github/workflows/build.yml@main | |
with: | |
# esphome/onju-voice-microwakeword.yaml | |
files: | | |
esphome/onju-voice.yaml | |
esphome-version: latest | |
release-summary: "Check the release notes for more information." | |
release-url: ${{ github.event_name == 'release' && github.event.release.html_url || (github.event_name == 'workflow_dispatch' && inputs.release-url) || '' }} | |
release-version: ${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'workflow_dispatch' && inputs.version) || '' }} | |
build-docs: | |
name: Build documentation | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v4.2.2 | |
- name: 🏗️ Set up Node.js | |
uses: actions/setup-node@v4.1.0 | |
with: | |
node-version: 20.x | |
- name: 🏗️ Install Docusaurus dependencies | |
run: npm install --frozen-lockfile --non-interactive | |
working-directory: docs | |
- name: 🚀 Build Docusaurus | |
run: npm run build | |
working-directory: docs | |
- name: ⬆️ Upload documentation artifact | |
uses: actions/upload-artifact@v4.4.3 | |
with: | |
name: site | |
path: docs/build | |
consolidate: | |
name: Consolidate firmwares | |
runs-on: ubuntu-latest | |
needs: | |
- build-firmware | |
- build-docs | |
steps: | |
- name: ⬇️ Download documentation artifact | |
uses: actions/download-artifact@v4.1.8 | |
with: | |
name: site | |
path: site | |
- name: ⬇️ Download firmware artifacts | |
uses: actions/download-artifact@v4.1.8 | |
with: | |
pattern: onju-voice* | |
path: firmwares | |
- name: 🧹 Remove intermediate version folder | |
run: |- | |
for d in firmwares/*/*; do | |
if [ -d "$d" ]; then | |
mv $d/* $d/../ | |
rm -rf $d | |
fi | |
done | |
- name: 🧪 Display firmware artifacts | |
run: ls -lR | |
- name: 🗂️ Move firmware files to docs | |
run: | | |
mkdir output | |
cp -R site/* output/ | |
cp -R firmwares/* output/firmware/ | |
# - name: Move manifest files to root and modify paths | |
# run: | | |
# for device in firmwares/*; do | |
# device=$(basename $device) | |
# jq --arg device "$device" \ | |
# '.builds[].ota.path |= $device + "/" + . | (.builds[].parts // [])[].path |= $device + "/" + .' \ | |
# firmwares/$device/manifest.json > output/$device-manifest.json | |
# done | |
- name: 🧪 Display firmware artifacts | |
run: ls -lR | |
- name: ⬆️ Upload pages artifacts | |
uses: actions/upload-pages-artifact@v3.0.1 | |
with: | |
path: output | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: consolidate | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: 🏗️ Setup Github Pages | |
uses: actions/configure-pages@v5.0.0 | |
- name: 🚀 Deploy to Github Pages | |
uses: actions/deploy-pages@v4.0.5 | |
id: deployment |