8
n8n 中文网amn8n.com

将生成的 HTML 发布为 GitHub Gist 并返回可共享的 URL

初级

这是一个File Management领域的自动化工作流,包含 4 个节点。主要使用 Set, HttpRequest, ExecuteWorkflowTrigger 等节点。 使用 GitHub Gist 和 HTML 预览发布 HTML 内容

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "bGQ3XjWBjCOEVByz",
  "meta": {
    "instanceId": "26bd595441827fb23edb0643d6d240e79b0b8993d278e90950f16e18bf9e3c4a"
  },
  "name": "将生成的 HTML 发布为 GitHub Gist 并返回可共享的 URL",
  "tags": [],
  "nodes": [
    {
      "id": "27b9084e-f5ac-4352-a83b-c9ba07fc83f1",
      "name": "创建 Gist",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        208,
        208
      ],
      "parameters": {
        "url": "https://api.github.com/gists",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"description\": \"Auto-rendered HTML\",\n  \"public\": false,\n  \"files\": {\n    \"report.html\": {\n      \"content\": {{ JSON.stringify($json.html) }}\n    }\n  }\n} ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "n8n"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "bL0vFGWGmVL1598x",
          "name": "GitHub API"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "81a700fe-209e-427a-be64-2094e708420e",
      "name": "当被其他工作流执行时",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        0,
        208
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "html"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "34b106bf-39de-4aed-86fa-56df8cd1db85",
      "name": "设置 URL",
      "type": "n8n-nodes-base.set",
      "position": [
        432,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1627b23c-18a5-4180-ac01-534e65172481",
              "name": "URL",
              "type": "string",
              "value": "={{ \"https://htmlpreview.github.io/?\" + $json.files[\"report.html\"].raw_url }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0e4f5280-7cae-4ff2-9407-9b72b5cfeb59",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 520,
        "content": "## 将 GitHub API 密钥添加到\"创建 Gist\"节点"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "zt6t5IiKkPc9Z4Ku",
    "executionOrder": "v1"
  },
  "versionId": "65e95b86-419b-4bda-b178-cec08559b6ee",
  "connections": {
    "Create Gist": {
      "main": [
        [
          {
            "node": "Set URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Create Gist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

初级 - 文件管理

需要付费吗?

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

工作流信息
难度等级
初级
节点数量4
分类1
节点类型4
难度说明

适合 n8n 新手,包含 1-5 个节点的简单工作流

作者
Open Paws

Open Paws

@openpaws

Open Paws is a nonprofit building open-source AI tools to accelerate animal advocacy. We create machine learning models and automation workflows trained on real-world campaign data to help end industrial animal exploitation. All tools are free, transparent, and designed for real-world impact.

外部链接
在 n8n.io 查看

分享此工作流