Skip to content

Commit cab60db

Browse files
authored
Update webflash.yml
1 parent 74b9bcf commit cab60db

1 file changed

Lines changed: 37 additions & 86 deletions

File tree

.github/workflows/webflash.yml

Lines changed: 37 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,67 @@
1-
name: Web Flash (Pages) - ESP Web Tools
1+
name: Web Flash (from IDF Build artifact)
22

33
on:
4-
push:
5-
tags: [ "v*" ]
6-
release:
7-
types: [published]
8-
workflow_dispatch:
9-
10-
permissions:
11-
contents: read
12-
pages: write
13-
id-token: write
14-
15-
concurrency:
16-
group: "pages"
17-
cancel-in-progress: true
4+
workflow_run:
5+
workflows: ["IDF Build (ESP32-P4)"]
6+
types: [completed]
187

198
jobs:
20-
build-and-publish:
9+
publish:
10+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
2111
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
actions: read
15+
pages: write
16+
id-token: write
2217

2318
steps:
24-
- name: Checkout (with submodules)
25-
uses: actions/checkout@v4
19+
- name: Download build artifact from triggering run
20+
uses: actions/download-artifact@v5
2621
with:
27-
submodules: recursive
22+
# We named the artifact with the build run_id in the IDF workflow
23+
name: tab5-build-${{ github.event.workflow_run.id }}
24+
# v5 supports cross-run downloads when given run-id & token/permissions
25+
run-id: ${{ github.event.workflow_run.id }}
26+
path: _dl
2827

29-
- name: Prepare ccache
30-
run: mkdir -p .ccache
31-
32-
- name: Restore ccache
33-
uses: actions/cache@v4
28+
- name: Set up Python and install esptool
29+
uses: actions/setup-python@v5
3430
with:
35-
path: .ccache
36-
key: ccache-${{ runner.os }}-${{ github.ref_name }}-${{ hashFiles('**/CMakeLists.txt', 'sdkconfig*', '**/*.[ch]', '**/*.cpp') }}
37-
restore-keys: |
38-
ccache-${{ runner.os }}-${{ github.ref_name }}-
39-
ccache-${{ runner.os }}-
31+
python-version: '3.x'
32+
- run: python -m pip install --upgrade pip esptool
4033

41-
- name: Build firmware (ESP-IDF 5.4.x / esp32p4)
42-
uses: espressif/esp-idf-ci-action@v1
43-
env:
44-
IDF_TARGET: esp32p4
45-
with:
46-
esp_idf_version: v5.4.2
47-
target: esp32p4
48-
path: .
49-
extra_docker_args: "-v ${{ github.workspace }}/.ccache:/root/.ccache -e CCACHE_DIR=/root/.ccache"
50-
51-
- name: Collect firmware
52-
id: fw
34+
- name: Merge firmware (ESP-IDF v4+ requires single merged file for Web Tools)
35+
working-directory: _dl/platforms/tab5/build
5336
run: |
54-
mkdir -p site
55-
FWBIN="$(ls build/*.bin | head -n1)"
56-
test -n "$FWBIN"
57-
cp "$FWBIN" site/firmware.bin
58-
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
59-
VER="${GITHUB_REF_NAME}"
60-
else
61-
VER="$(git rev-parse --short HEAD)"
62-
fi
63-
echo "ver=$VER" >> $GITHUB_OUTPUT
37+
mkdir -p ../../../site
38+
# Use the exact flash layout created by the build:
39+
python -m esptool --chip esp32p4 merge_bin \
40+
-o ../../../site/firmware-merged.bin \
41+
"@flash_args"
6442
65-
- name: Create manifest.json for ESP Web Tools
43+
- name: Create ESP Web Tools manifest
44+
working-directory: _dl/site
6645
run: |
67-
cat > site/manifest.json << JSON
46+
VER="${{ github.event.workflow_run.run_number }}"
47+
cat > manifest.json << 'JSON'
6848
{
6949
"name": "M5Tab5 User Demo",
70-
"version": "${{ steps.fw.outputs.ver }}",
50+
"version": "R${{ github.event.workflow_run.run_number }}",
7151
"builds": [{
7252
"chipFamily": "ESP32",
7353
"parts": [
74-
{ "path": "firmware.bin", "offset": 0 }
54+
{ "path": "firmware-merged.bin", "offset": 0 }
7555
]
7656
}]
7757
}
7858
JSON
7959
80-
- name: Create flash.html (install button)
81-
run: |
82-
cat > site/flash.html << 'HTML'
83-
<!doctype html>
84-
<html lang="en">
85-
<head>
86-
<meta charset="utf-8" />
87-
<meta name="viewport" content="width=device-width, initial-scale=1" />
88-
<title>M5Tab5 – Web Flash</title>
89-
<!-- Load ESP Web Tools button -->
90-
<script type="module" src="https://unpkg.com/esp-web-tools@10/dist/web/install-button.js?module"></script>
91-
<style>
92-
body{font-family:system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
93-
display:grid; place-items:center; min-height:100dvh; margin:0; background:#0b0c10;}
94-
.card{background:#121418; color:#e6e6e6; padding:24px; border-radius:16px; box-shadow:0 10px 30px #0008;}
95-
h1{margin:0 0 8px}
96-
p{opacity:.8; margin:0 0 16px}
97-
esp-web-install-button{--mdc-theme-primary:#38bdf8}
98-
</style>
99-
</head>
100-
<body>
101-
<div class="card">
102-
<h1>M5Tab5 – Web Flash</h1>
103-
<p>Connect your Tab5 (ESP32-P4), then click Install.</p>
104-
<esp-web-install-button manifest="manifest.json"></esp-web-install-button>
105-
</div>
106-
</body>
107-
</html>
108-
HTML
109-
11060
- name: Upload Pages artifact
11161
uses: actions/upload-pages-artifact@v3
11262
with:
113-
path: site
63+
path: _dl/site
11464

11565
- name: Deploy to GitHub Pages
66+
id: deployment
11667
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)