Add Gitea restart workflow and link-style "Run again" for the public view
Test and deploy enrollment demo / test (push) Successful in 36s
Test and deploy enrollment demo / deploy (push) Successful in 1m13s

The server deployment cannot mount the Docker socket safely, so the web
view's button now opens the Gitea page for a workflow_dispatch workflow
that recreates the stack and replays the demo. Gitea handles who may run it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 21:54:24 +03:30
co-authored by Claude Sonnet 5.5
parent bf40b92c52
commit 37ca9d4da1
7 changed files with 49 additions and 8 deletions
+2
View File
@@ -23,6 +23,8 @@ services:
- "${VIEWER_BIND:-127.0.0.1}:8099:8080"
environment:
COMPOSE_PROJECT: crypto-interop-spike
# When set (server deployment), the page offers "Run again" as a link to the Gitea workflow page.
RESTART_URL: ${RESTART_URL:-}
volumes:
- logs:/logs
# The "Run again" button is NOT available here; it needs compose.restart.yaml (Docker socket).
+11 -2
View File
@@ -239,7 +239,10 @@ for (const [id, cls] of [['onlychecks', 'only-checks'], ['hidedetail', 'hide-det
// refresh shows the whole run again.
// Run again: ask the viewer server to restart the whole demo (backend, boards and a fresh broker).
// The custom header is required by the server so other web pages cannot trigger it.
let cfg = { restart: false, restartUrl: '' };
document.getElementById('restart').addEventListener('click', async () => {
// Public deployment: no Docker access here, so send the user to Gitea, which requires a login.
if (!cfg.restart && cfg.restartUrl) { window.open(cfg.restartUrl, '_blank', 'noopener'); return; }
document.getElementById('restart').disabled = true;
try {
const r = await fetch('/api/restart', { method: 'POST', headers: { 'X-Demo-Action': 'restart' } });
@@ -259,7 +262,13 @@ function resetView() {
}
// The restart button only exists when the server was started with restart support enabled.
fetch('/api/config').then(r => r.json()).then(c => { if (!c.restart) document.getElementById('restart').style.display = 'none'; })
fetch('/api/config').then(r => r.json()).then(c => {
cfg = c;
const b = document.getElementById('restart');
if (c.restart) return;
if (c.restartUrl) { b.innerHTML = '&#8635; Run again (via Gitea)'; b.title = 'Opens Gitea, where you run the "Restart demo" workflow (login required)'; }
else b.style.display = 'none';
})
.catch(() => { document.getElementById('restart').style.display = 'none'; });
buildCards();
@@ -271,7 +280,7 @@ es.onmessage = e => add(JSON.parse(e.data));
es.addEventListener('reset', resetView);
es.addEventListener('status', e => {
const s = JSON.parse(e.data);
document.getElementById('restart').disabled = s.busy;
if (cfg.restart) document.getElementById('restart').disabled = s.busy;
document.getElementById('status').textContent = s.busy || s.text !== 'ready' ? s.text : liveText;
});
</script>
+5 -2
View File
@@ -45,7 +45,10 @@ var (
logDir = "/logs"
// The restart button needs the Docker socket; it is only enabled when the deployment says so.
restartEnabled = os.Getenv("RESTART_ENABLED") == "1"
re = regexp.MustCompile(`^(\d\d:\d\d:\d\d\.\d{3}) \[([a-z-]+)\] (.*)$`)
// Without the Docker socket the page can still offer "Run again" as a link to this URL (the
// Gitea page that runs the restart workflow); Gitea then does the authentication.
restartURL = os.Getenv("RESTART_URL")
re = regexp.MustCompile(`^(\d\d:\d\d:\d\d\.\d{3}) \[([a-z-]+)\] (.*)$`)
)
// tail remembers how far a file has been read and any incomplete last line.
@@ -294,7 +297,7 @@ func main() {
json.NewEncoder(w).Encode(lines)
})
http.HandleFunc("/api/config", func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]bool{"restart": restartEnabled})
json.NewEncoder(w).Encode(map[string]any{"restart": restartEnabled, "restartUrl": restartURL})
})
http.HandleFunc("/api/restart", func(w http.ResponseWriter, r *http.Request) {
if !restartEnabled {