Skip to content

Commit caa8df6

Browse files
committed
Pages: auto-deploy on docs changes using latest release assets
1 parent 29538ba commit caa8df6

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

.github/workflows/pages-webflasher.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ on:
55
inputs:
66
release_tag:
77
description: "Release tag to publish to GitHub Pages (example: v1.3.4)"
8-
required: true
8+
required: false
9+
push:
10+
branches: [main]
11+
paths:
12+
- "docs/**"
13+
- ".github/workflows/pages-webflasher.yml"
914

1015
jobs:
1116
pages:
1217
name: Deploy Web Flasher (Pages)
1318
runs-on: ubuntu-24.04
19+
concurrency:
20+
group: github-pages
21+
cancel-in-progress: true
1422
permissions:
1523
contents: read
1624
pages: write
@@ -27,10 +35,28 @@ jobs:
2735
with:
2836
enablement: true
2937

38+
- name: Resolve release tag
39+
id: meta
40+
env:
41+
INPUT_TAG: ${{ inputs.release_tag }}
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
set -euo pipefail
45+
TAG="${INPUT_TAG:-}"
46+
if [ -z "$TAG" ]; then
47+
TAG="$(gh api "repos/${GITHUB_REPOSITORY}/releases/latest" --jq .tag_name)"
48+
fi
49+
if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then
50+
echo "Could not resolve a release tag. Provide release_tag input or publish a Release." >&2
51+
exit 1
52+
fi
53+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
54+
echo "Using tag: $TAG"
55+
3056
- name: Download release assets
3157
env:
3258
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
TAG: ${{ inputs.release_tag }}
59+
TAG: ${{ steps.meta.outputs.tag }}
3460
run: |
3561
set -euo pipefail
3662
rm -rf docs/firmware
@@ -59,7 +85,7 @@ jobs:
5985
6086
- name: Build manifest.json
6187
env:
62-
TAG: ${{ inputs.release_tag }}
88+
TAG: ${{ steps.meta.outputs.tag }}
6389
run: |
6490
set -euo pipefail
6591
python -c "import os, json; from pathlib import Path; tag=os.getenv('TAG','manual'); manifest={'name':'projectZero ESP32-C5','version':tag,'build':tag,'chipFamily':'ESP32-C5','parts':[{'path':'firmware/bootloader.bin','offset':8192},{'path':'firmware/partition-table.bin','offset':32768},{'path':'firmware/projectZero.bin','offset':131072}]}; Path('docs/manifest.json').write_text(json.dumps(manifest, indent=2) + '\\n')"
@@ -72,4 +98,3 @@ jobs:
7298
- name: Deploy to GitHub Pages
7399
id: deployment
74100
uses: actions/deploy-pages@v4
75-

0 commit comments

Comments
 (0)