mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 12:07:28 +01:00
* feat(previews): a status mode that says where a change sent with `ask` is An ask to a preview's builder answers with a runId and a commandId, and nothing could read them back from Actions: a change that had not landed after half an hour was waiting, running or failed, and there was no way to tell. `status` reads the run (and the queued command) through the deployed app as the operator, the same way the other modes act. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9KbVEpxKLC9nhKhpWncU1 * feat(previews): status also says whether the cloud builder is running and what its update drain last did Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9KbVEpxKLC9nhKhpWncU1 * feat(previews): status shows the runner restart's state and each agent the drain waits on Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9KbVEpxKLC9nhKhpWncU1 * fix(runner): a day-old Claude with no status file no longer holds every runner update The drain restarts the box runner only when no agent is working, and a Claude with no status file counts as working ("unknown is not idle"). Two such processes, 6 days and 1.8 days old, held the drain open while all six other agents sat idle: the runner stayed on 12 October's code, and since the commands route holds new work for a builder that is behind (src/lib/runner-update-hold.ts), no new task started on the cloud builder at all. Center SOM's change sat "Waiting for a builder" for over half an hour, and so did everything else. Every current Claude writes its status file for as long as it runs, so one that has written none for a day (LOKI_RUNNER_LEFTOVER_SECS, default 86400) is a leftover — a session from a CLI that predates the file, or a helper — and no longer holds the restart. A young one with no file, a Claude whose file says it is working, and every other agent CLI are still busy. Pinned in test-drain-and-restart-runner.sh. Also on this branch: previews.yml `status` (a run's state, the queued command, the runner, its drain and each agent's status — names and states only), which is how this was found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9KbVEpxKLC9nhKhpWncU1 --------- Co-authored-by: Claude <noreply@anthropic.com>
117 lines
4.7 KiB
YAML
117 lines
4.7 KiB
YAML
name: Previews
|
|
|
|
# Make a prospect preview reachable, and keep every preview reachable.
|
|
#
|
|
# create make the preview in Loki (as the operator), give it its own address
|
|
# <address>.orangecat.ch, and prove that address answers over HTTPS.
|
|
# website /change "Improve this site" for a live website, as the operator —
|
|
# the consultation, the brief, the folder, the host and the build,
|
|
# on the deployed app. How the flow is dogfooded without a browser.
|
|
# check open a preview as its owner — the site, the before-and-after tour
|
|
# and its first pictures — and print what answered.
|
|
# move give a preview a new address (and name); the old address goes away.
|
|
# ask send a preview's builder a change, in words (name = the project).
|
|
# status where a change sent with `ask` is (run = its runId, command = its commandId).
|
|
# heal every preview folder on the box has its address and answers.
|
|
# Runs on a clock, so a lost Caddy vhost is put back before anyone
|
|
# opens the link (an address without one shows ERR_SSL_PROTOCOL_ERROR).
|
|
#
|
|
# The access code is normally set in the app ("set the preview code to ..." in
|
|
# Loki's chat, or the Access code field in Build a preview). It can also be given
|
|
# here once: it is masked in the logs, but a public repo shows a run's inputs, so
|
|
# delete the run right after.
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
mode:
|
|
description: "create, website, check, move, ask, status or heal"
|
|
required: true
|
|
default: "heal"
|
|
website:
|
|
description: "website: the live site to improve, e.g. center-com.ru"
|
|
required: false
|
|
changes:
|
|
description: "website: what the owner wants, in words (optional); ask: the change"
|
|
required: false
|
|
fixes:
|
|
description: "website: consultation check ids to fix, comma-separated (src/config/site-consult)"
|
|
required: false
|
|
answers:
|
|
description: "website: one-tap answers, e.g. goal:buy,look:refresh"
|
|
required: false
|
|
address:
|
|
description: "create/check/move: the subdomain, e.g. francesco"
|
|
required: false
|
|
run:
|
|
description: "status: the runId an ask answered with"
|
|
required: false
|
|
command:
|
|
description: "status: the commandId an ask answered with (optional)"
|
|
required: false
|
|
to:
|
|
description: "move: the new subdomain, e.g. tsentr-som"
|
|
required: false
|
|
name:
|
|
description: "create/move: who it is for, e.g. Francesco Tarallo; ask: the project"
|
|
required: false
|
|
about:
|
|
description: "create: links, place, trade"
|
|
required: false
|
|
code:
|
|
description: "create/website: set the access code (masked in logs; delete the run afterwards)"
|
|
required: false
|
|
schedule:
|
|
- cron: "17 */6 * * *"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# One writer of the box's Caddy at a time, and never alongside a deploy.
|
|
concurrency:
|
|
group: deploy-prod
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
previews:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
env:
|
|
HETZNER_IP: ${{ vars.HETZNER_IP }}
|
|
MODE: ${{ inputs.mode || 'heal' }}
|
|
ADDRESS: ${{ inputs.address }}
|
|
TO: ${{ inputs.to }}
|
|
RUN: ${{ inputs.run }}
|
|
COMMAND: ${{ inputs.command }}
|
|
WEBSITE: ${{ inputs.website }}
|
|
CHANGES: ${{ inputs.changes }}
|
|
FIXES: ${{ inputs.fixes }}
|
|
ANSWERS: ${{ inputs.answers }}
|
|
NAME: ${{ inputs.name }}
|
|
ABOUT: ${{ inputs.about }}
|
|
CODE: ${{ inputs.code }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: SSH setup
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
printf '%s\n' "${{ secrets.HETZNER_SSH_KEY }}" > ~/.ssh/id_deploy
|
|
chmod 600 ~/.ssh/id_deploy
|
|
ssh-keyscan -H "$HETZNER_IP" >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- name: Ensure
|
|
env:
|
|
DEPLOY_KEY_PATH: /home/runner/.ssh/id_deploy
|
|
run: |
|
|
[ -z "$CODE" ] || echo "::add-mask::$CODE"
|
|
case "$MODE" in
|
|
create) bash scripts/hetzner/ensure-preview.sh create "$ADDRESS" "$NAME" "$ABOUT" "$CODE" ;;
|
|
website) bash scripts/hetzner/ensure-preview.sh website "$WEBSITE" "$CHANGES" "$FIXES" "$ANSWERS" "$CODE" ;;
|
|
check) bash scripts/hetzner/ensure-preview.sh check "$ADDRESS" ;;
|
|
move) bash scripts/hetzner/ensure-preview.sh move "$ADDRESS" "$TO" "$NAME" ;;
|
|
ask) bash scripts/hetzner/ensure-preview.sh ask "$NAME" "$CHANGES" ;;
|
|
status) bash scripts/hetzner/ensure-preview.sh status "$RUN" "$COMMAND" ;;
|
|
heal) bash scripts/hetzner/ensure-preview.sh heal ;;
|
|
*) echo "::error::mode is create, website, check, move, ask, status or heal"; exit 1 ;;
|
|
esac
|