n8n自动更新
中级
这是一个DevOps领域的自动化工作流,包含 12 个节点。主要使用 If, Code, HttpRequest, ScheduleTrigger 等节点。 使用版本检查和Portainer Webhook自动化n8n更新
前置要求
- •可能需要目标 API 的认证凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "5TGOTlmPdfRCmmfe",
"meta": {
"instanceId": "dcb1c5ac6ea74a8d48a18ebc0df6103a2b23cb36997704a343a62b1831c8eccd"
},
"name": "n8n 自动更新",
"tags": [],
"nodes": [
{
"id": "f1b6e1f4-1de3-4334-8a6a-72917d5612e3",
"name": "Portainer Webhook",
"type": "n8n-nodes-base.httpRequest",
"position": [
1184,
80
],
"parameters": {
"url": "https://portainer.tld.com/api/stacks/webhooks/606e8503-8824-43b1-a67c-cf95abbee1a8",
"method": "POST",
"options": {
"response": {
"response": {}
},
"allowUnauthorizedCerts": false
}
},
"typeVersion": 4.2
},
{
"id": "8cde31ed-6b9c-4451-8ce7-95b846d7e356",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-80,
80
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 16,
"triggerAtMinute": 8
}
]
}
},
"typeVersion": 1.2
},
{
"id": "8756bed1-42d0-4f5f-904c-2d5294002f74",
"name": "获取最新的 n8n 版本",
"type": "n8n-nodes-base.httpRequest",
"position": [
144,
80
],
"parameters": {
"url": "https://registry.npmjs.org/n8n/latest",
"options": {
"fullResponse": false
}
},
"typeVersion": 2
},
{
"id": "938334e9-c0b1-476e-a816-4269946d7a41",
"name": "条件判断",
"type": "n8n-nodes-base.if",
"position": [
864,
80
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a2d169a3-7aa2-46f5-bdb2-f0d53a011b5c",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $('Get the latest n8n version').item.json.version }}",
"rightValue": "={{ $json.versionCli }}"
}
]
}
},
"typeVersion": 2.2,
"alwaysOutputData": false
},
{
"id": "4802535d-c004-442a-bbd1-610d540e924d",
"name": "本地 n8n 版本",
"type": "n8n-nodes-base.code",
"position": [
640,
80
],
"parameters": {
"jsCode": "const text = $input.first().json.data;\nconst match = text.match(/n8n_version_info\\{[^}]*version=\"(v[\\d.]+)\"/);\n\nif (match) {\n const version = match[1].replace(/^v/, ''); // v entfernen\n return [{ json: { versionCli: version } }];\n} else {\n throw new Error(\"Version info not found in metrics output\");\n}\n"
},
"typeVersion": 2
},
{
"id": "cee62d71-075b-4bf0-a800-b4fa2fee9ebe",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-112,
-16
],
"parameters": {
"width": 160,
"height": 272,
"content": "## Cron 定时任务"
},
"typeVersion": 1
},
{
"id": "94d2e06e-daf3-4260-929c-584144fbe486",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
80,
-16
],
"parameters": {
"width": 208,
"height": 272,
"content": "## 最新版本"
},
"typeVersion": 1
},
{
"id": "e1a8d5f8-d672-4475-9ea0-e2eda0028702",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
320,
-16
],
"parameters": {
"width": 224,
"height": 272,
"content": "## 获取指标"
},
"typeVersion": 1
},
{
"id": "47c26e66-ba89-4903-a948-22b1162bf1e5",
"name": "获取本地 n8n 指标",
"type": "n8n-nodes-base.httpRequest",
"position": [
368,
80
],
"parameters": {
"url": "https://127.0.0.1/metrics",
"options": {
"allowUnauthorizedCerts": true
}
},
"typeVersion": 4.2
},
{
"id": "4bf82532-cc70-4071-83f6-3550392b1590",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
576,
-16
],
"parameters": {
"width": 224,
"height": 272,
"content": "## 已安装版本"
},
"typeVersion": 1
},
{
"id": "b11bd405-761f-4328-af3e-0a79c985f654",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
832,
-16
],
"parameters": {
"width": 256,
"height": 272,
"content": "## 如果有可用更新"
},
"typeVersion": 1
},
{
"id": "559a1933-1bc6-4fc4-bcb2-2ef76364dc0e",
"name": "便利贴5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1120,
-16
],
"parameters": {
"width": 256,
"height": 272,
"content": "## 开始更新"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "1f5d34fd-158e-44a5-8438-f235f4265d00",
"connections": {
"If": {
"main": [
[
{
"node": "Portainer Webhook",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get the latest n8n version",
"type": "main",
"index": 0
}
]
]
},
"local n8n version": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Get local n8n metrics": {
"main": [
[
{
"node": "local n8n version",
"type": "main",
"index": 0
}
]
]
},
"Get the latest n8n version": {
"main": [
[
{
"node": "Get local n8n metrics",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 开发运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
UniFi控制器:检查并在新发布时升级
通过SSH和Telegram通知自动化UniFi控制器更新
If
Ssh
Code
+5
11 节点Dominic Spatz
开发运维
自动化API正常运行时间监控与即时停机警报
API正常运行时间监控,含WhatsApp警报和Google表格管理
If
Code
Wait
+6
17 节点Oneclick AI Squad
开发运维
自动化网站正常运行时间监控与邮件警报及GitHub状态页更新
自动化网站正常运行时间监控与邮件警报及GitHub状态页更新
If
Code
Gmail
+6
19 节点Linearloop Team
开发运维
自动化n8n工作流备份至GitHub并追踪删除
自动化n8n工作流备份至GitHub并追踪删除
If
N8n
Set
+13
31 节点Marcial Ambriz
开发运维
n8n备份管家v3
工作流自动备份至GitHub,支持邮件/Telegram通知
If
Code
Gmail
+6
21 节点Builds.Cool
开发运维
Typebot 流程与 GitHub 双向同步,使用 Typebot API
Typebot 流程与 GitHub 双向同步,使用 Typebot API
If
Set
Code
+12
31 节点Marcial Ambriz
开发运维