每日自动化工作流备份至 GitHub
中级
这是一个Engineering, DevOps, AI领域的自动化工作流,包含 13 个节点。主要使用 If, N8n, Set, Github, Aggregate 等节点,结合人工智能技术实现智能自动化。 每日自动化工作流备份至 GitHub
前置要求
- •GitHub Personal Access Token
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"nodes": [
{
"id": "2aafc10f-0bb7-419f-a6b3-fa90f5f68653",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
100,
-20
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
},
{
"id": "da87b4f8-4507-456b-bfc3-3ae7d9400449",
"name": "检索工作流",
"type": "n8n-nodes-base.n8n",
"position": [
580,
-20
],
"parameters": {
"filters": {},
"requestOptions": {}
},
"typeVersion": 1
},
{
"id": "6cd7d968-6fa0-4ab0-ac58-ceb15c8b7b4a",
"name": "聚合",
"type": "n8n-nodes-base.aggregate",
"position": [
420,
-20
],
"parameters": {
"options": {},
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "name"
}
]
}
},
"typeVersion": 1
},
{
"id": "854f6e82-babb-474e-a138-2a6c398fd60e",
"name": "列出仓库文件",
"type": "n8n-nodes-base.github",
"position": [
260,
-20
],
"webhookId": "354d699e-44b0-4444-9d31-af7fd4ff5561",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": ""
},
"filePath": "=",
"resource": "file",
"operation": "list",
"repository": {
"__rl": true,
"mode": "list",
"value": ""
},
"authentication": "oAuth2"
},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "8abba016-1f34-420a-b10b-3c8e44297725",
"name": "更新文件",
"type": "n8n-nodes-base.github",
"position": [
1380,
-100
],
"webhookId": "27218087-8df7-474d-a39f-70cfa9c34ec8",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": ""
},
"filePath": "={{ $('Retrieve workflows').item.json.name.replace(/\\s+/g, '-').toLowerCase() }}-{{ $('Retrieve workflows').item.json.tags[0].name }}.json",
"resource": "file",
"operation": "edit",
"repository": {
"__rl": true,
"mode": "list",
"value": ""
},
"fileContent": "={{ $('To base64').item.json.data }}",
"commitMessage": "=backup-{{ $('Commit date & file name').item.json.commitDate }}",
"authentication": "oAuth2"
},
"typeVersion": 1
},
{
"id": "d55efcc7-5873-4c9a-b374-b7b31814905b",
"name": "上传文件",
"type": "n8n-nodes-base.github",
"position": [
1380,
60
],
"webhookId": "ce4b561b-acb9-4cd8-b76f-4928dada9674",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": ""
},
"filePath": "={{ $('Retrieve workflows').item.json.name.replace(/\\s+/g, '-').toLowerCase() }}-{{ $('Retrieve workflows').item.json.tags[0].name }}.json",
"resource": "file",
"repository": {
"__rl": true,
"mode": "list",
"value": ""
},
"fileContent": "={{ $('To base64').item.json.data }}",
"commitMessage": "=backup-{{ $node['Commit date & file name'].json.commitDate }}",
"authentication": "oAuth2"
},
"typeVersion": 1
},
{
"id": "09909c9f-8a68-4670-8396-65fae9be51ff",
"name": "检查文件是否存在",
"type": "n8n-nodes-base.if",
"position": [
1220,
-20
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $('Aggregate').item.json.name }}",
"value2": "={{ $('Retrieve workflows').item.json.name.replace(/\\s+/g, '-').toLowerCase() }}-{{ $('Retrieve workflows').item.json.tags[0].name }}.json",
"operation": "contains"
}
]
}
},
"typeVersion": 1
},
{
"id": "43990124-eac4-4c57-9da3-39053d9e5850",
"name": "JSON 文件",
"type": "n8n-nodes-base.convertToFile",
"position": [
740,
-20
],
"parameters": {
"mode": "each",
"options": {
"format": true
},
"operation": "toJson"
},
"typeVersion": 1.1
},
{
"id": "956de457-4d05-4ea8-be7b-390861a739d4",
"name": "转换为 base64",
"type": "n8n-nodes-base.extractFromFile",
"position": [
900,
-20
],
"parameters": {
"options": {},
"operation": "binaryToPropery"
},
"typeVersion": 1
},
{
"id": "fc258985-2621-42a3-9bc6-01048a92b702",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
240,
-160
],
"parameters": {
"color": 5,
"width": 300,
"height": 380,
"content": "### 从 Github 检索之前的文件名"
},
"typeVersion": 1
},
{
"id": "1bfedd8f-1921-4f33-aa45-7ab612f26059",
"name": "提交日期和文件名",
"type": "n8n-nodes-base.set",
"position": [
1060,
-20
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "fe4a36ef-9f04-40e3-99bd-cc517a49b440",
"name": "commitDate",
"type": "string",
"value": "={{ $now.format('dd-MM-yyyy/H:mm') }}"
},
{
"id": "b0fe1bcc-e79c-4a6b-b8b4-44222c8bf4e8",
"name": "fileName",
"type": "string",
"value": "={{ $('Retrieve workflows').item.json.name.replace(/\\s+/g, '-').toLowerCase() }}-{{ $('Retrieve workflows').item.json.tags[0].name }}.json"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "2f36af66-12ca-451a-a1ca-c5a71b94b644",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
560,
-160
],
"parameters": {
"color": 3,
"width": 460,
"height": 380,
"content": "### 从 n8n 检索并处理工作流"
},
"typeVersion": 1
},
{
"id": "dc914f31-e6b5-43b0-8a4e-f9f46118fa30",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1040,
-160
],
"parameters": {
"color": 4,
"width": 460,
"height": 380,
"content": "### 提交 + 编辑/创建文件(如需要)"
},
"typeVersion": 1
}
],
"connections": {
"Aggregate": {
"main": [
[
{
"node": "Retrieve workflows",
"type": "main",
"index": 0
}
]
]
},
"Json file": {
"main": [
[
{
"node": "To base64",
"type": "main",
"index": 0
}
]
]
},
"To base64": {
"main": [
[
{
"node": "Commit date & file name",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "List files from repo",
"type": "main",
"index": 0
}
]
]
},
"Retrieve workflows": {
"main": [
[
{
"node": "Json file",
"type": "main",
"index": 0
}
]
]
},
"Check if file exists": {
"main": [
[
{
"node": "Update file",
"type": "main",
"index": 0
}
],
[
{
"node": "Upload file",
"type": "main",
"index": 0
}
]
]
},
"List files from repo": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Commit date & file name": {
"main": [
[
{
"node": "Check if file exists",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 工程, 开发运维, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Airtable完整备份
Airtable数据库备份到S3
If
Set
Aws S3
+8
19 节点Autonomous Work
工程
github_repo_workflows_sync
n8n 工作流的双向 GitHub 工作流同步与版本控制
If
N8n
Set
+8
25 节点Wikus Bergh
人工智能
仅从数据库架构生成 SQL 查询 - AI 驱动
仅从数据库架构生成 SQL 查询 - AI 驱动
If
Set
Merge
+11
29 节点Yulia
工程
[模板] AI宠物店 v8
🐶 AI宠物店助手 - 集成GPT-4o、Google日历和WhatsApp/Instagram/Facebook
If
N8n
Set
+38
244 节点Amanda Benks
销售
AI 代理餐厅 [模板]
🤖 WhatsApp、Instagram 和 Messenger 的 AI 餐厅助手
If
N8n
Set
+37
239 节点Amanda Benks
其他
动态GitHub工作流
🔄 Workflow Repos8r:n8n工作流的GitHub版本控制用户界面
N8n
Set
Code
+8
44 节点RealSimple Solutions
工程