Three workflows that connect the services from episodes 1 to 7: a Forgejo push becomes a phone notification, an Uptime Kuma outage writes and closes its own incident page in Outline, and a nightly schedule writes one ops digest. The point of the episode is the split between webhooks and the editor. Caddy publishes only the webhook path prefixes under the n8n host and answers an empty 404 for everything else, so the editor stays reachable over the mesh from episode 5 and never gets a login page on the open internet. Also in here: - n8n pinned to a version instead of :latest, after episode 7 showed that every restore is otherwise an upgrade - the 2.x environment that actually matters, including the file access restriction pointed at one directory rather than the root - the Forgejo allowed host list, without which a webhook to a private address is silently dropped - fixed subnets for both docker networks, after a restore handed them out in the other order and quietly broke the mesh route - a note on the encryption key: it decrypts every stored credential, it lives in the n8n volume, and a backup without it restores a hub that cannot log in Claude-Session: https://claude.ai/code/session_01Md8yhBKp5e7xMmCyxoEgdm
107 lines
3 KiB
JSON
107 lines
3 KiB
JSON
{
|
|
"name": "A - Deploy notifier",
|
|
"nodes": [
|
|
{
|
|
"id": "a1",
|
|
"name": "Forgejo push",
|
|
"type": "n8n-nodes-base.webhook",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
0,
|
|
0
|
|
],
|
|
"webhookId": "REPLACE_ON_IMPORT",
|
|
"parameters": {
|
|
"httpMethod": "POST",
|
|
"path": "forgejo-push",
|
|
"responseMode": "onReceived",
|
|
"options": {}
|
|
}
|
|
},
|
|
{
|
|
"id": "a2",
|
|
"name": "Format message",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
240,
|
|
0
|
|
],
|
|
"parameters": {
|
|
"jsCode": "\n// The Forgejo push payload, reduced to the five things a human wants to know.\nconst b = $json.body ?? $json;\nconst repo = b.repository?.full_name ?? 'unknown/unknown';\nconst branch = String(b.ref ?? '').replace('refs/heads/', '');\nconst commits = Array.isArray(b.commits) ? b.commits : [];\nconst head = commits[commits.length - 1] ?? {};\nconst author = head.author?.name ?? b.pusher?.username ?? b.sender?.username ?? 'unknown';\nconst subject = String(head.message ?? '').split('\\n')[0].slice(0, 120);\nconst short = String(head.id ?? '').slice(0, 8);\nconst link = head.url ?? b.compare_url ?? b.repository?.html_url ?? '';\n\nreturn [{\n json: {\n pushTitle: repo + ' / ' + branch,\n text: commits.length + ' commit(s) by ' + author + '\\n' + short + ' ' + subject,\n link,\n repo, branch, author, subject, short,\n commitCount: commits.length,\n },\n}];\n"
|
|
}
|
|
},
|
|
{
|
|
"id": "a3",
|
|
"name": "Push to ntfy",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [
|
|
480,
|
|
0
|
|
],
|
|
"parameters": {
|
|
"method": "POST",
|
|
"url": "http://ntfy/deploys",
|
|
"authentication": "genericCredentialType",
|
|
"genericAuthType": "httpBasicAuth",
|
|
"sendHeaders": true,
|
|
"headerParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "X-Title",
|
|
"value": "={{ $json.pushTitle }}"
|
|
},
|
|
{
|
|
"name": "X-Priority",
|
|
"value": "3"
|
|
},
|
|
{
|
|
"name": "X-Click",
|
|
"value": "={{ $json.link }}"
|
|
}
|
|
]
|
|
},
|
|
"sendBody": true,
|
|
"contentType": "raw",
|
|
"rawContentType": "text/plain",
|
|
"body": "={{ $json.text }}",
|
|
"options": {}
|
|
},
|
|
"credentials": {
|
|
"httpBasicAuth": {
|
|
"id": "REPLACE_WITH_YOUR_CREDENTIAL_ID",
|
|
"name": "ntfy (n8n user)"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"connections": {
|
|
"Forgejo push": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Format message",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Format message": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Push to ntfy",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
}
|
|
},
|
|
"settings": {
|
|
"executionOrder": "v1"
|
|
},
|
|
"active": false
|
|
}
|