ci: auto-deploy qbit-maid to Komodo after image push #63

Merged
jblu merged 5 commits from dev-komodo-deploy into main 2026-10-27 00:31:12 -05:00
Owner

What this does

Deploys the qbit-maid stack on Komodo (https://k.jonb.io) automatically after the container image is pushed to the registry.

Why not a webhook

The existing stack webhook fires on git push, which happens before Gitea Actions builds and pushes the image. Komodo would pull the previous :latest, deploy it, and report success — the new code never lands. This calls the Komodo API from the workflow instead, after the push completes.

Changes

  • .gitea/scripts/komodo-deploy.sh — POSTs /execute/DeployStack, fails on non-200, then polls /read/GetUpdate until Complete and checks success, printing Komodo's log on failure. Supports KOMODO_TARGET_TYPE=procedure for future use.
  • .gitea/workflows/docker.yml — deploys stack qbit-maid after the image push (required).
  • .gitea/workflows/docker-dev.yml — deploys vars.KOMODO_STACK_DEV; skips cleanly when unset so dev builds never fail.
  • test_komodo_deploy.py — 15 unittest cases against a mock Komodo API.
  • .gitea/workflows/test.yml — runs the tests on push to main/dev* and on PRs.
  • docs/komodo-deploy-plan.md — design notes and setup instructions.

Bugs found and fixed during review

  1. Permission denied on first run — this repo has core.fileMode=false, so chmod +x never reached git and the runner got the script as 100644. Fixed by marking it 100755 in the index and invoking via sh.
  2. Shell-dependent exit code — :? exits 1 under bash but 2 under dash (the Ubuntu runner's sh), so two tests passed locally and failed in CI. Replaced with explicit if [ -z ... ] checks so every failure path exits 1.

Verification

  • 15/15 tests pass locally and in CI (test.yml green on b2b8f6c).
  • docker-dev.yml green on the same commit.
  • Both workflows parse as valid YAML; script passes sh -n.

Before merging

  • Add Gitea secrets KOMODO_URL, KOMODO_API_KEY, KOMODO_API_SECRET
  • Confirm Auto Pull is enabled on stack qbit-maid (if off, deploys reuse the cached image and report success without changing anything)
  • Consider removing the existing stack webhook — it now redeploys the stale image on every push
  • Set KOMODO_STACK_DEV repository variable if you have a dev stack

The first real deploy happens on the next push to main after merge.

## What this does Deploys the `qbit-maid` stack on Komodo (`https://k.jonb.io`) automatically after the container image is pushed to the registry. ## Why not a webhook The existing stack webhook fires on `git push`, which happens **before** Gitea Actions builds and pushes the image. Komodo would pull the previous `:latest`, deploy it, and report success — the new code never lands. This calls the Komodo API from the workflow instead, after the push completes. ## Changes - **`.gitea/scripts/komodo-deploy.sh`** — POSTs `/execute/DeployStack`, fails on non-200, then polls `/read/GetUpdate` until `Complete` and checks `success`, printing Komodo's log on failure. Supports `KOMODO_TARGET_TYPE=procedure` for future use. - **`.gitea/workflows/docker.yml`** — deploys stack `qbit-maid` after the image push (required). - **`.gitea/workflows/docker-dev.yml`** — deploys `vars.KOMODO_STACK_DEV`; skips cleanly when unset so dev builds never fail. - **`test_komodo_deploy.py`** — 15 unittest cases against a mock Komodo API. - **`.gitea/workflows/test.yml`** — runs the tests on push to `main`/`dev*` and on PRs. - **`docs/komodo-deploy-plan.md`** — design notes and setup instructions. ## Bugs found and fixed during review 1. **`Permission denied` on first run** — this repo has `core.fileMode=false`, so `chmod +x` never reached git and the runner got the script as `100644`. Fixed by marking it `100755` in the index and invoking via `sh`. 2. **Shell-dependent exit code** — `:?` exits 1 under bash but 2 under dash (the Ubuntu runner's `sh`), so two tests passed locally and failed in CI. Replaced with explicit `if [ -z ... ]` checks so every failure path exits 1. ## Verification - 15/15 tests pass locally and in CI (`test.yml` green on `b2b8f6c`). - `docker-dev.yml` green on the same commit. - Both workflows parse as valid YAML; script passes `sh -n`. ## Before merging - [x] Add Gitea secrets `KOMODO_URL`, `KOMODO_API_KEY`, `KOMODO_API_SECRET` - [x] Confirm **Auto Pull** is enabled on stack `qbit-maid` (if off, deploys reuse the cached image and report success without changing anything) - [ ] Consider removing the existing stack webhook — it now redeploys the stale image on every push - [ ] Set `KOMODO_STACK_DEV` repository variable if you have a dev stack The first real deploy happens on the next push to `main` after merge.
jblu added 5 commits 2026-10-27 00:26:36 -05:00
ci: auto-deploy to Komodo stack after image push
ci / docker (push) Failing after 44s
ef002b2fce
Adds a shared .gitea/scripts/komodo-deploy.sh that calls the Komodo
/execute/DeployStack API after the image is pushed, then polls
/read/GetUpdate until the deploy completes.

A push webhook cannot do this correctly: it fires before the image
exists in the registry, so Komodo would redeploy the previous :latest.

- docker.yml deploys stack 'qbit-maid' (required)
- docker-dev.yml deploys vars.KOMODO_STACK_DEV, skipped when unset
ci: fix Komodo deploy step permission denied
ci / docker (push) Successful in 5m11s
45908b8f6e
core.fileMode is false in this repo, so the exec bit on
komodo-deploy.sh was not recorded and the runner hit
'Permission denied'. Mark the file executable in the index and
invoke it via 'sh' so the step no longer depends on the mode bit.
test: cover komodo-deploy.sh against a mock Komodo API
ci / docker (push) Successful in 21s
test / komodo-deploy-script (push) Failing after 21s
003217a2b8
15 unittest cases exercising the real script end to end: target
selection, auth headers, request shape, success/failure, HTTP 401/400,
unreachable host, polling to completion, and timeout.

Runs in CI via .gitea/workflows/test.yml on push to main/dev* and on
pull requests. No network or live Komodo instance required.
fix: deterministic exit code for missing Komodo env vars
test / komodo-deploy-script (push) Successful in 16s
ci / docker (push) Successful in 48s
test / komodo-deploy-script (pull_request) Successful in 16s
b2b8f6c10d
':?' exits 1 under bash but 2 under dash (the Ubuntu runner's sh),
so the two missing-variable tests failed in CI while passing locally.
Replace with explicit checks so every failure path exits 1.
jblu merged commit 147758a1e8 into main 2026-10-27 00:31:12 -05:00
jblu deleted branch dev-komodo-deploy 2026-10-27 00:31:12 -05:00
Sign in to join this conversation.