A JavaScript GitHub Action that invokes a MaidCafe action on a managed host through the cloud relay and waits for the result.
The action enqueues a webhook request on the MaidCafe cloud
(POST /api/daemons/:id/webhook-requests), then polls the request until the
daemon has picked it up and reported the result. The daemon polls the relay
every 15 seconds and pickup is not throttled by the workspace polling quota,
so a run takes seconds to start plus the action's own runtime before the
result is known. The job fails when the request never completes, the daemon
rejects it, or the action exits non-zero; the relay result (stdout, error) is
printed to the run log.
Actions carry no secret; authentication is the cloud credential scoped to the daemon and action names. Use this for CI/CD. Secret-protected webhooks are meant for humans and other systems — see the MaidCafe webhook docs.
Two modes:
relay(default) — invoke through the MaidCafe cloud. The action enqueues a webhook request and polls until the daemon picks it up and reports. Works anywhere the runner can reach the cloud; the daemon needs no inbound connectivity.direct— call the daemon's HTTP API (POST /api/v1/actions/:name) synchronously. No cloud, no polling; the runner must be able to reach the daemon'slistenaddress (default127.0.0.1:8747), e.g. via an SSH tunnel or Tailscale. Authenticates with the daemon metrics secret (daemon.metricsSecret), not the cloud credential.
-
Create a credential scoped to the target daemon and action:
curl -X POST https://mkc.solsynth.dev/api/credentials \ -H 'Authorization: Bearer <solar-token>' \ -H 'Content-Type: application/json' \ -d '{"label":"ci-backup","host_ids":["<host-id>"],"action_names":["backup"]}'
The response contains the plain token (
mk_...) — returned only once.host_idsare the daemon's stable host id (the file the daemon stores in/etc/maidcafe/host-id), so the credential survives re-registrations. -
Store the token as a repository secret named
MAIDCAFE_TOKEN. It authenticates user routes in place of a Solarpass token, and the daemon records its label asinvoked_byin the audit log. -
Find the daemon id:
GET /api/daemons?workspace_id=<id>(or the cloud page's host detail).
| Input | Required | Default | Meaning |
|---|---|---|---|
mode |
no | relay |
relay (via MaidCafe cloud) or direct (daemon HTTP API) |
daemon_id |
relay | — | MaidCafe daemon (host) id |
daemon_url |
direct | — | Daemon HTTP API base URL (e.g. http://127.0.0.1:8747) |
action |
yes | — | Action name configured on the daemon |
token |
yes | — | Cloud credential token (mk_...) in relay mode; daemon metrics secret in direct mode |
body |
no | {} |
JSON body piped to the action on stdin |
api |
no | https://mkc.solsynth.dev |
MaidCafe cloud base URL (relay mode) |
timeout_minutes |
no | 10 |
Max wait for the daemon to finish (relay mode) |
| Output | Meaning |
|---|---|
result_code |
HTTP status the daemon reported: 200 success, 502 non-zero exit, 504 timeout, 401/404/413/429 rejected |
result_body |
Base64 of the action's stdout |
jobs:
backup:
runs-on: ubuntu-latest
steps:
- name: Run backup on the managed host
id: backup
uses: Solsynth/MaidFlow@v2
with:
daemon_id: d0f2f0c2-...
action: backup
body: '{"job":"incremental"}'
token: ${{ secrets.MAIDCAFE_TOKEN }}
timeout_minutes: 15
- name: Print the result
run: echo "exit ${{ steps.backup.outputs.result_code }}"Pin to a full commit SHA in production (uses: Solsynth/MaidFlow@<sha>).
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
# Example: tunnel to the daemon's loopback listener.
- name: Open SSH tunnel to the host
run: ssh -fN -L 8747:127.0.0.1:8747 host-01
- name: Run cleanup directly on the daemon
id: cleanup
uses: Solsynth/MaidFlow@v2
with:
mode: direct
daemon_url: http://127.0.0.1:8747
action: cleanup
body: '{"retention_days":14}'
token: ${{ secrets.MAIDCAFE_DAEMON_METRICS_SECRET }}The daemon runs the action synchronously and returns the result in the
response, so direct mode does not poll. Result codes match the daemon's HTTP
API: 200 success, 502 non-zero exit, 504 timeout, 401 bad metrics
secret, 404 unknown action, 413 oversized body, 429 concurrency
exhausted.