- Go 93.9%
- Shell 5.6%
- Dockerfile 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Shared runners are disabled on this project and the only available runner (ARM Runner Hetzner) has run_untagged=false, so untagged jobs failed with stuck_pending_no_matching_runners. |
||
| cmd/automations | ||
| internal | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| check-reboot.sh | ||
| docker-compose.example.yml | ||
| Dockerfile | ||
| Dockerfile.release | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
| renovate.json | ||
| scan-docker-images.sh | ||
automations
Single Go service replacing 13 active n8n workflows (previously
ghcr.io/n8n-io/n8n:2.41.7, ~1GB). Webhook receiver + Telegram notifier +
IMAP invoice forwarder. No database, state is one UID file under /data.
Ported workflows
Paths are the original n8n webhook UUIDs, so existing callers (cal.com, Transaktio, TimeTag, monitoring scripts) keep working unchanged.
| n8n workflow | Route | Action |
|---|---|---|
| transaktio.de user deleted | POST /webhook/e7f7e9ad-7bd5-4c26-8499-dc9027c0519d |
Telegram → -5042764222 |
| New transaktio.de user | POST /webhook/148f65f8-bca1-4625-bde7-f6173556d7a9 |
Telegram → -5042764222 |
| cal.com booking KonfiApp | POST /webhook/b8186dfc-16b7-454c-8321-885f3d1f26f4 |
formatted booking (de-DE, Europe/Berlin) → -5042764222 |
| cal.com booking KirchApp | POST /webhook/cc069ad4-67f2-47f1-9f45-54c14eb52db |
formatted booking → -5042764222 |
| cal.com booking pd | POST /webhook/759d6b0c-0de5-4b17-a11f-9489157f88f7 |
static text → -5042764222 |
| TimeTag Feedback | POST /webhook/9f48de5f-f88c-4013-9cfe-63d9d89823e2 |
type/mail/message → -5042764222 |
| TimeTag Sale | POST /webhook/4a8cf26a-6890-45c7-98dc-85c75118da42 |
amount/currency/mode → -5042764222 |
| New TimeTag Sale | POST /webhook/4e58ad82-2478-45b0-9043-f3b891639ea5 |
static text → -5042764222 |
| KirchNah Newsletter Signup | POST /webhook/d7e5ef52-4964-4da2-b8f2-1e75752d5aae |
static text → -5042764222 |
| storage info pd servers | `GET | POST /webhook/dab14db5-10a5-4a78-89c7-94cc48f2daf9?server=&usage=` |
| reboot-required watch (3 VPS) | `GET | POST /webhook/reboot-required?server=&reboot=&pkgs=&kernel=` |
| docker image vuln report | `GET | POST /webhook/21177d81-d06f-436d-9c5c-720e2c3c2e50` |
| auto forward invoices to sevdesk | IMAP poll (no HTTP) | billers/invoice-inboxes + attachment → SMTP to autobox@sevdesk.email |
| github repo visibility watch | hourly poll per repo (no HTTP) | configured owner/repo slugs, exists/private transitions → one shared Telegram chat |
| website text-change watch | hourly poll per URL (no HTTP) | configured URLs, normalized-text changes → Telegram with diff + snapshot links, archive served at /sitewatch/ |
| link appearance watch | hourly poll per listing page (no HTTP) | new <a href> containing a substring filter → Telegram |
GET /healthz returns {"ok":true}.
Configuration (env only)
n8n credentials are encrypted and cannot be exported — set these instead:
# required: Telegram bot token (n8n "Telegram account")
TELEGRAM_DEFAULT_TOKEN=
# weekly docker image report (webhook 21177d81... mails IMAP_USER)
OPENCODE_API_KEY= # OpenCode Go/Zen key (sk-...); unset = raw summary, no AI
OPENCODE_MODEL=glm-5.3-flash
OPENCODE_BASE_URL=https://opencode.ai/zen/v1
ADDR=:8080
IMAP invoice inbox (forwarder skipped if IMAP_PASSWORD/SMTP_PASSWORD unset)
IMAP_HOST=mail.philippdormann.de IMAP_PORT=993 IMAP_USER=philipp@philippdormann.de IMAP_PASSWORD= IMAP_MAILBOX=INBOX IMAP_POLL_INTERVAL=1m STATE_DIR=/data
SMTP_HOST=mail.philippdormann.de SMTP_PORT=587 SMTP_USER=philipp@philippdormann.de SMTP_PASSWORD= SMTP_TLS_MODE=starttls # starttls (default, required) | ssl — plaintext never used
SEVDESK_TARGET=autobox@sevdesk.email SEVDESK_FROM=philipp@philippdormann.de SEVDESK_SENDERS=billing@hetzner.com,noreply.billing@hetzner.com SEVDESK_RECIPIENTS=autoprocess-zjv0vo36mqug3cr62wbuuunq@philippdormann.de,e-rechnung-fom2x34i1e3tfxzqmfnq3h54@philippdormann.de
Repo watch: polls `GET /repos/<owner>/<repo>` every `REPO_WATCH_INTERVAL`
(default `1h`) for each slug in `REPO_WATCH_REPOS` (comma-separated
`owner/repo`, e.g. `REPO_WATCH_REPOS=Revisor01/Konfi-Quest,myorg/other`),
stores `{exists,private}` per repo in
`$STATE_DIR/repowatch_<owner>_<repo>.json`, and sends Telegram to the one
shared `REPO_WATCH_CHAT_ID` only on exists/private transitions (404 counts
as "not visible": deleted, renamed, or private). Malformed slugs are logged
and skipped. Transient API errors (403/429/5xx) keep the old state and never
notify. First poll per repo stores the baseline silently.
`REPO_WATCH_TOKEN`/`GITHUB_TOKEN` is optional (higher rate limit only;
warns without token above ~40 repos). Unset `REPO_WATCH_REPOS` or
`REPO_WATCH_CHAT_ID` disables the watcher — no repos are watched by
default.
Site watch: polls each URL in `SITE_WATCH_URLS` every
`SITE_WATCH_INTERVAL` (default `1h`), extracts visible text (scripts,
styles, tags stripped), and archives a new capture only when the
normalized-text hash changes. Each entry may override the interval
with a `|duration` suffix (e.g. `https://example.org/pricing|24h`).
Each capture stores raw HTML + text +
metadata under `$STATE_DIR/sitewatch/<slug>/<uuid>.*` (`slug` is the
stable sanitized-host + short-hash ID, `uuid` a random v4 per capture).
Raw HTML keeps only the last `SITE_WATCH_KEEP_HTML` captures per site
(default `20`); normalized text is kept forever so diffs stay computable.
Changes notify `SITE_WATCH_CHAT_ID` via the default Telegram bot with
`+added −removed` counts, a diff link and a snapshot link.
`SITE_WATCH_BASE_URL` must be the public absolute origin (e.g.
`https://n8n.philippdormann.de`) — Telegram only linkifies absolute
`https://` URLs, so without it the message contains relative
`/sitewatch/...` paths that are not clickable.
Viewer (open, no auth): `GET /sitewatch/` index, `GET /sitewatch/<slug>`
history, `GET /sitewatch/<slug>/<uuid>` archived snapshot (raw HTML while
retained, text fallback after pruning), `GET
/sitewatch/<slug>/diff?from=<uuid>&to=<uuid>` line diff (defaults to the
last two captures). Non-200 fetches keep the old state and never notify;
first poll per URL stores the baseline silently. Unset `SITE_WATCH_URLS`
or `SITE_WATCH_CHAT_ID` disables the watcher.
Link watch: polls each listing page in `LINK_WATCH_URLS` every
`LINK_WATCH_INTERVAL` (default `1h`), extracts `<a href>` links
(resolved to absolute URLs), and keeps only those containing
`LINK_WATCH_MATCH` (case-insensitive substring, e.g. `version`).
Previously unseen matches notify `LINK_WATCH_CHAT_ID` via the default
Telegram bot with the new URLs. Seen links persist in
`$STATE_DIR/linkwatch_<slug>.json` and only grow, so items that drop
off a paginated listing never re-notify. Non-200 fetches keep the old
state and never notify; first poll per URL stores the baseline
silently. Unset `LINK_WATCH_URLS` or `LINK_WATCH_CHAT_ID` disables the
watcher.
See `.env.example` and `docker-compose.example.yml`.
## Reboot-required watch (3 VPS)
No ping check — ping only proves up/down, not pending kernel/libc updates.
Ubuntu signals it via `/var/run/reboot-required` (+ `.pkgs`).
Each VPS pushes daily after `unattended-upgrades` (same script, hostname
distinguishes them). Server stays silent on `reboot=0`, sends one Telegram
message per `reboot=1` call (daily reminder until rebooted — intentional).
```bash
# on each VPS (pd-web, pd-mail, third host):
sudo install -m 755 check-reboot.sh /opt/automations/check-reboot.sh
# cron (06:30, after apt-daily-upgrade.timer ~06:09):
30 6 * * * /opt/automations/check-reboot.sh
# optional per-host override:
# SERVER_NAME=pd-web WEBHOOK_URL=https://n8n.philippdormann.de/webhook/reboot-required
Protocol on GET|POST /webhook/reboot-required:
?server=<name>&reboot=<0|1>&pkgs=<...>&kernel=<uname -r>orPOST {"server","reboot":0|1|bool,"pkgs","kernel"}({query:{...}}wrapper accepted like storage webhook).reboot=0→{"ok":true,"notified":false}.reboot=1→ Telegram🔁 Reboot required: <server>+ running kernel + package list (500 runes cap) →{"ok":true,"notified":true}.
Behavioral differences vs n8n (intentional)
- Forwarded invoice subject prefix changed
via n8n:→via automations:. - Sender/recipient matching is case-insensitive (n8n IF was case-sensitive).
- cal.com date renders
Mo 05.01.2026 14:30(Europe/Berlin, German short weekday). - Storage webhook accepts JSON body
{server,usage}/{query:{...}}in addition to query params; below 85% returns{"ok":true,"notified":false}. - IMAP tracks last UID in
$STATE_DIR/imap_lastuid(n8ntrackLastMessageId).
Run
go test ./...
go run ./cmd/automations
docker build -t automations:local .
trivy image --scanners vuln --severity HIGH,CRITICAL automations:local
Docker image vulnerability report
No trivy runs on prod hosts (pd-web, pd-mail). They push a running-image
inventory only; all scanning happens on the CI server where trivy runs
locally via docker. The webhook enriches findings with OpenCode AI fix
suggestions and mails the report to IMAP_USER.
# web/mail cron (Sun 03:30, one `docker ps` + curl, no trivy):
30 3 * * 0 /opt/automations/scan-docker-images.sh inventory --post
# CI cron (Sun 04:00, trivy scan + report):
0 4 * * 0 /opt/automations/scan-docker-images.sh scan
Protocol on POST|GET /webhook/21177d81-d06f-436d-9c5c-720e2c3c2e50:
POST {"type":"inventory","host","arch","images"}→ stored under/data,{"ok":true}.GET→ merged{"images":[...],"arch":{image:arch},"hosts":{...}}for the CI scanner (arch pins the trivy platform per image).POST {"type":"report","host","scanned_at","images","findings"}→ OpenCode summary + SMTP mail toIMAP_USER,{"ok":true,"emailed":true}.
Only CVE/package/version/severity leaves the hosts. Image layers, env vars
and compose files are never transmitted. Without OPENCODE_API_KEY the raw
trivy summary is mailed without AI suggestions.
The AI brief is ownership-aware (OWN_REGISTRIES, default
registry.gitlab.com): images we build get exact rebuild guidance, while
third-party images (postgres, redis, …) get 1–2 researched alternatives that
are minimal, actively maintained, multi-arch and near-zero-CVE, with
migration caveats. The endpoint family follows OPENCODE_BASE_URL:
.../chat/completions for most models, .../responses for
muse-spark/grok/gpt-luna (plus OPENCODE_SESSION_ID for Go routing).