Skip to content

Commit 26181f2

Browse files
authored
Merge pull request #73 from SenaxInc/copilot/add-github-action-preview
Add GitHub Actions website preview for 112025 Viewer
2 parents 1389038 + cb14ae6 commit 26181f2

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/html-render.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ on:
66
paths:
77
- 'TankAlarm-092025-Server-Hologram/*.ino'
88
- 'TankAlarm-112025-Server-BluesOpta/*.ino'
9+
- 'TankAlarm-112025-Viewer-BluesOpta/*.ino'
910
- '.github/workflows/html-render.yml'
1011
pull_request:
1112
branches: [main, master]
1213
paths:
1314
- 'TankAlarm-092025-Server-Hologram/*.ino'
1415
- 'TankAlarm-112025-Server-BluesOpta/*.ino'
16+
- 'TankAlarm-112025-Viewer-BluesOpta/*.ino'
1517
- '.github/workflows/html-render.yml'
1618
workflow_dispatch:
1719

@@ -187,6 +189,35 @@ jobs:
187189
print(f'Extracted config generator HTML: {len(config_html)} bytes')
188190
EOF
189191
192+
- name: Extract and render HTML for 112025 Viewer
193+
run: |
194+
mkdir -p /tmp/html-112025-viewer
195+
python3 << 'EOF'
196+
import re
197+
198+
ino_file = 'TankAlarm-112025-Viewer-BluesOpta/TankAlarm-112025-Viewer-BluesOpta.ino'
199+
output_dir = '/tmp/html-112025-viewer'
200+
201+
with open(ino_file, 'r', encoding='utf-8', errors='ignore') as f:
202+
content = f.read()
203+
204+
# Find the VIEWER_DASHBOARD_HTML constant
205+
html_pattern = r'static const char VIEWER_DASHBOARD_HTML\[\] PROGMEM = R"HTML\((.*?)\)HTML"'
206+
match = re.search(html_pattern, content, re.DOTALL)
207+
208+
if match:
209+
html_content = match.group(1)
210+
211+
# Replace the STR(WEB_REFRESH_SECONDS) macro with a placeholder value
212+
html_content = re.sub(r'\)HTML" STR\(WEB_REFRESH_SECONDS\) R"HTML\(', '30', html_content)
213+
214+
output_file = output_dir + '/dashboard.html'
215+
with open(output_file, 'w', encoding='utf-8') as out:
216+
out.write(html_content)
217+
218+
print(f'Extracted viewer dashboard HTML: {len(html_content)} bytes')
219+
EOF
220+
190221
- name: Take screenshots with Playwright
191222
run: |
192223
node << 'EOF'
@@ -251,6 +282,31 @@ jobs:
251282
}
252283
}
253284
285+
// Screenshot 112025 Viewer pages
286+
const dir112025Viewer = '/tmp/html-112025-viewer';
287+
const output112025Viewer = 'TankAlarm-112025-Viewer-BluesOpta/screenshots';
288+
289+
if (fs.existsSync(dir112025Viewer)) {
290+
fs.mkdirSync(output112025Viewer, { recursive: true });
291+
const files = fs.readdirSync(dir112025Viewer);
292+
293+
for (const file of files) {
294+
if (file.endsWith('.html')) {
295+
const htmlPath = path.join(dir112025Viewer, file);
296+
const screenshotName = file.replace('.html', '.png');
297+
const screenshotPath = path.join(output112025Viewer, screenshotName);
298+
299+
try {
300+
await page.goto('file://' + htmlPath, { waitUntil: 'networkidle' });
301+
await page.screenshot({ path: screenshotPath, fullPage: true });
302+
console.log(`Screenshot saved: ${screenshotPath}`);
303+
} catch (error) {
304+
console.error(`Error capturing ${file}:`, error.message);
305+
}
306+
}
307+
}
308+
}
309+
254310
await browser.close();
255311
}
256312
@@ -302,13 +358,29 @@ jobs:
302358
*Last updated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")*
303359
EOF
304360
361+
- name: Generate WEBSITE_PREVIEW.md for 112025 Viewer
362+
run: |
363+
cat > TankAlarm-112025-Viewer-BluesOpta/WEBSITE_PREVIEW.md << 'EOF'
364+
# Website Preview - TankAlarm 112025 Viewer
365+
366+
This document contains screenshots of the web interface served by the TankAlarm-112025-Viewer-BluesOpta.
367+
368+
## Dashboard
369+
![Dashboard](screenshots/dashboard.png)
370+
371+
---
372+
*Screenshots automatically generated by GitHub Actions*
373+
*Last updated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")*
374+
EOF
375+
305376
- name: Commit and push changes
306377
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
307378
run: |
308379
git config --local user.email "github-actions[bot]@users.noreply.github.com"
309380
git config --local user.name "github-actions[bot]"
310381
git add TankAlarm-092025-Server-Hologram/WEBSITE_PREVIEW.md TankAlarm-092025-Server-Hologram/screenshots/
311382
git add TankAlarm-112025-Server-BluesOpta/WEBSITE_PREVIEW.md TankAlarm-112025-Server-BluesOpta/screenshots/
383+
git add TankAlarm-112025-Viewer-BluesOpta/WEBSITE_PREVIEW.md TankAlarm-112025-Viewer-BluesOpta/screenshots/
312384
git diff --staged --quiet || git commit -m "Update website preview screenshots [skip ci]"
313385
git push origin HEAD:${{ github.head_ref || github.ref_name }}
314386
env:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Website Preview - TankAlarm 112025 Viewer
2+
3+
This document contains screenshots of the web interface served by the TankAlarm-112025-Viewer-BluesOpta.
4+
5+
## Dashboard
6+
![Dashboard](screenshots/dashboard.png)
7+
8+
---
9+
*Screenshots automatically generated by GitHub Actions*

0 commit comments

Comments
 (0)