8
n8n 中文网amn8n.com

从GitHub恢复您的工作流

中级

这是一个Other领域的自动化工作流,包含 9 个节点。主要使用 N8n, Set, Github, SplitOut, HttpRequest 等节点。 从GitHub恢复您的工作流

前置要求
  • GitHub Personal Access Token
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "XYz1JYUXFHFVdlLj",
  "meta": {
    "instanceId": "e634e668fe1fc93a75c4f2a7fc0dad807ca318b79654157eadb9578496acbc76",
    "templateCredsSetupCompleted": true
  },
  "name": "从GitHub恢复您的工作流",
  "tags": [
    {
      "id": "2RWIfLUVCa0bnmGX",
      "name": "N8n",
      "createdAt": "2025-03-06T09:58:39.214Z",
      "updatedAt": "2025-03-06T09:58:39.214Z"
    }
  ],
  "nodes": [
    {
      "id": "cab3a8b6-4106-4449-8b12-d57cc93477ab",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1040,
        -160
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "733ce565-bd6e-4297-8166-52f79d68a0f2",
      "name": "全局变量",
      "type": "n8n-nodes-base.set",
      "position": [
        -840,
        -160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6cf546c5-5737-4dbd-851b-17d68e0a3780",
              "name": "repo.owner",
              "type": "string",
              "value": "BeyondspaceStudio"
            },
            {
              "id": "452efa28-2dc6-4ea3-a7a2-c35d100d0382",
              "name": "repo.name",
              "type": "string",
              "value": "n8n-backup"
            },
            {
              "id": "81c4dc54-86bf-4432-a23f-22c7ea831e74",
              "name": "repo.path",
              "type": "string",
              "value": "workflows"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e20b94c3-f33a-48ff-b1df-aa8acc8f6f44",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1460,
        -280
      ],
      "parameters": {
        "width": 320,
        "height": 420,
        "content": "## 从GitHub恢复"
      },
      "typeVersion": 1
    },
    {
      "id": "34db1b48-6629-4760-b264-e782949d34bc",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -280
      ],
      "parameters": {
        "color": 4,
        "width": 150,
        "height": 80,
        "content": "## 编辑此节点 👇"
      },
      "typeVersion": 1
    },
    {
      "id": "088b7e98-001c-4a24-b8c1-44c82285b894",
      "name": "获取指定路径中的所有文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1000,
        160
      ],
      "parameters": {
        "url": "=https://api.github.com/repos/{{ $json.repo.owner }}/{{ $json.repo.name }}/contents/{{ $json.repo.path }}",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "githubApi"
      },
      "credentials": {
        "githubApi": {
          "id": "3FYHiPFtycAFT8V0",
          "name": "GitHub account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9a148510-3e72-4cb1-a194-a7c90122be7e",
      "name": "拆分结果",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -760,
        160
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "path"
      },
      "typeVersion": 1
    },
    {
      "id": "cbcfa116-056b-4493-8f74-0c9f3744a5d1",
      "name": "从GitHub获取文件内容",
      "type": "n8n-nodes-base.github",
      "position": [
        -540,
        160
      ],
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "name",
          "value": "BeyondspaceStudio"
        },
        "filePath": "={{ $('Get all files in given path').item.json.path }}",
        "resource": "file",
        "operation": "get",
        "repository": {
          "__rl": true,
          "mode": "name",
          "value": "n8n-backup"
        },
        "additionalParameters": {}
      },
      "credentials": {
        "githubApi": {
          "id": "3FYHiPFtycAFT8V0",
          "name": "GitHub account"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "78e7e4cd-dbde-4767-9b26-503063ea35fc",
      "name": "将文件转换为JSON",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -320,
        160
      ],
      "parameters": {
        "options": {},
        "operation": "fromJson"
      },
      "typeVersion": 1
    },
    {
      "id": "ee851935-f8fd-4999-a4c3-50e0c28b915a",
      "name": "恢复n8n工作流",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -100,
        160
      ],
      "parameters": {
        "operation": "create",
        "requestOptions": {},
        "workflowObject": "={{ JSON.stringify($json.data) }}"
      },
      "credentials": {
        "n8nApi": {
          "id": "dzYjDgtEXtpRPKhe",
          "name": "n8n account"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f8d4cd76-d31e-4842-9ec3-64ab3253728c",
  "connections": {
    "Globals": {
      "main": [
        [
          {
            "node": "Get all files in given path",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split the result": {
      "main": [
        [
          {
            "node": "Get file content from GitHub",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert files to JSON": {
      "main": [
        [
          {
            "node": "Restore n8n Workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all files in given path": {
      "main": [
        [
          {
            "node": "Split the result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get file content from GitHub": {
      "main": [
        [
          {
            "node": "Convert files to JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Globals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 其他

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量9
分类1
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
bangank36

bangank36

@bangank36

Automation specialist with 10+ years of experience helping SME website owners streamline their workflows—specializing in Squarespace, Shopify, and WordPress. Book an initial consultation for custom n8n automation using my link.

外部链接
在 n8n.io 查看

分享此工作流