mirror of
https://github.com/athom-tech/esp32-configs.git
synced 2026-07-28 04:05:53 +00:00
120 lines
3.3 KiB
YAML
120 lines
3.3 KiB
YAML
name: Publish Pages
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'static/**'
|
|
- '.github/workflows/publish-pages.yml'
|
|
workflow_run:
|
|
workflows:
|
|
- Publish Firmware
|
|
types:
|
|
- completed
|
|
pull_request:
|
|
paths:
|
|
- 'static/**'
|
|
- '.github/workflows/publish-pages.yml'
|
|
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout source code
|
|
uses: actions/checkout@v6
|
|
|
|
- run: mkdir -p output/firmware
|
|
|
|
- name: Build
|
|
uses: actions/jekyll-build-pages@v1
|
|
with:
|
|
source: ./static
|
|
destination: ./output
|
|
|
|
- name: Fetch firmware files
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
releases="$(
|
|
gh release list \
|
|
--exclude-drafts \
|
|
--exclude-pre-releases \
|
|
--limit 100 \
|
|
--json tagName,isLatest,publishedAt \
|
|
--jq '[.[] | select(.tagName | startswith("esphome-"))] | sort_by(.publishedAt) | reverse'
|
|
)"
|
|
|
|
if [ "$(jq 'length' <<< "${releases}")" -eq 0 ]; then
|
|
echo '{"latest": null, "versions": []}' > output/firmware/versions.json
|
|
exit 0
|
|
fi
|
|
|
|
latest_tag="$(jq -r 'map(select(.isLatest == true))[0].tagName // .[0].tagName' <<< "${releases}")"
|
|
|
|
jq -n --arg latest "${latest_tag#esphome-}" '{latest: $latest, versions: []}' \
|
|
> output/firmware/versions.json
|
|
|
|
jq -r '.[].tagName' <<< "${releases}" | while IFS= read -r tag; do
|
|
version="${tag#esphome-}"
|
|
target="output/firmware/${version}"
|
|
mkdir -p "${target}"
|
|
gh release download "${tag}" --dir "${target}" --pattern '*'
|
|
|
|
if [ ! -f "${target}/devices.json" ]; then
|
|
echo "Release ${tag} does not include devices.json." >&2
|
|
continue
|
|
fi
|
|
|
|
if [ "${tag}" = "${latest_tag}" ]; then
|
|
cp "${target}/"* output/firmware/
|
|
fi
|
|
|
|
jq --arg version "${version}" \
|
|
--arg tag "${tag}" \
|
|
--slurpfile devices "${target}/devices.json" \
|
|
'.versions += [{
|
|
version: $version,
|
|
tag: $tag,
|
|
devices: ($devices[0].devices | map(.manifest = ("firmware/" + $version + "/" + (.manifest | sub("^firmware/"; "")))))
|
|
}]' output/firmware/versions.json > output/firmware/versions.tmp
|
|
mv output/firmware/versions.tmp output/firmware/versions.json
|
|
done
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v5
|
|
with:
|
|
path: output
|
|
retention-days: 1
|
|
|
|
publish:
|
|
if: github.event_name != 'pull_request'
|
|
name: Publish
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- build
|
|
permissions:
|
|
pages: write
|
|
id-token: write
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
steps:
|
|
- name: Setup Pages
|
|
uses: actions/configure-pages@v6
|
|
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@v5
|