8
n8n 中文网amn8n.com

从GitHub推送生成Twitter和LinkedIn社交帖子

高级

这是一个Multimodal AI领域的自动化工作流,包含 18 个节点。主要使用 If, Merge, Github, Twitter, Webhook 等节点。 基于GitHub README/CHANGELOG更新使用GPT-4o和OAuth自动生成社交帖子

前置要求
  • GitHub Personal Access Token
  • Twitter API 凭证
  • HTTP Webhook 端点(n8n 会自动生成)
  • LinkedIn API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "zMl1xguA65ATPxMh",
  "meta": {
    "instanceId": "6bad1eba185697a960de5bc9203d6bff2fd56440a0b5303c382e0b1537a2a568",
    "templateCredsSetupCompleted": true
  },
  "name": "从 GitHub 推送生成 Twitter 和 LinkedIn 社交帖子",
  "tags": [],
  "nodes": [
    {
      "id": "29f468dd-8822-4de7-9bf7-0205e8b51b12",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -640,
        -144
      ],
      "webhookId": "70b80513-b93c-4749-9a06-e78d4f1f2d23",
      "parameters": {
        "path": "70b80513-b93c-4749-9a06-e78d4f1f2d23",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "a991ef0a-48ef-4ccf-98c6-587edddafa96",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        400,
        -80
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "a19b66f5-0927-4c59-8343-f2cea29feb5e",
      "name": "获取 README",
      "type": "n8n-nodes-base.github",
      "position": [
        64,
        -208
      ],
      "webhookId": "eab25bcf-6820-4ee6-ab43-7ec9f5a9e413",
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "name",
          "value": "jorge210488"
        },
        "filePath": "README.md",
        "resource": "file",
        "operation": "get",
        "repository": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $json.body.repository.name }}"
        },
        "additionalParameters": {}
      },
      "credentials": {
        "githubApi": {
          "id": "O2s7MSmQAwSFAbN5",
          "name": "GitHub account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "b3ae8e15-dd37-4207-a78c-4b18b72c9cb8",
      "name": "获取 CHANGELOG",
      "type": "n8n-nodes-base.github",
      "position": [
        64,
        32
      ],
      "webhookId": "eab25bcf-6820-4ee6-ab43-7ec9f5a9e413",
      "parameters": {
        "owner": {
          "__rl": true,
          "mode": "name",
          "value": "jorge210488"
        },
        "filePath": "CHANGELOG.md",
        "resource": "file",
        "operation": "get",
        "repository": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $json.body.repository.name }}"
        },
        "additionalParameters": {}
      },
      "credentials": {
        "githubApi": {
          "id": "O2s7MSmQAwSFAbN5",
          "name": "GitHub account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "9229a69b-fe35-4a25-a8d8-bc3e1f6d8894",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        -448,
        -144
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fb7ff717-d8a0-44ed-9053-1e88d50f88de",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{\n  ($json.body.commits ?? []).some(c =>\n    [ ...(c.added ?? []), ...(c.modified ?? []), ...(c.removed ?? []) ]\n      .some(f => String(f).toLowerCase().includes('changelog'))\n  )\n}}",
              "rightValue": "="
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4e9ebbbd-9c37-4dbe-a9b6-dc0f72a85877",
      "name": "无操作,不执行任何操作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -256,
        48
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e35435d4-f3f8-44f1-ac78-21efda7076ac",
      "name": "聚合",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        560,
        -80
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "82c95a95-4a00-405d-a826-9c387a3f76be",
      "name": "基础 LLM 链",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        832,
        -80
      ],
      "parameters": {
        "text": "=README: {{ $json.data[0].data }}\nCHANGELOG: {{ $json.data[1].data }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=# Role\n\nYou are a precise content generator for social media.\nYour input will be a JSON object with two string fields:\n\n* `README`: full project README in Markdown.\n* `CHANGELOG`: full changelog in Markdown.\n\n## Your task\n\nProduce **one JSON object** with exactly two keys:\n\n```json\n{\n  \"twitter\": \"<tweet in English, <=280 chars including the GitHub link>\",\n  \"linkedin\": \"<LinkedIn post in English, long-form>\"\n}\n```\n\nNo extra keys, no surrounding text, no Markdown fences.\n\n## Parsing rules (do not hallucinate)\n\n1. **Repository URL (required in both posts):**\n\n   * Extract the **first** URL that matches a GitHub repo pattern from `CHANGELOG` using a regex like:\n     `https?://github\\.com/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+`\n   * If not found in `CHANGELOG`, search `README` with the same regex.\n   * If still not found, **do not fabricate** a URL; instead, use the literal placeholder `https://github.com/REPO_MISSING`. (Keep generating the posts.)\n\n2. **Project name:**\n\n   * Prefer the first H1 (`# Title`) in `README`. If not present, infer a concise name from the first heading found. If impossible, use a short neutral name like “This project”.\n\n3. **First release or update determination:**\n\n   * From `CHANGELOG`, detect if this is the **first or only version** (e.g., version numbers like `v1.0.0`, \"Initial release\", or only one version section present).\n   * If first/only version → the post should clearly state it's a **new project/app/development** (e.g., “New project”, “Launching a new application”).\n   * If not first version → the post should state it’s an **update or improvement** (e.g., “Updating the project X”, “Improving the application X”).\n\n4. **Description & features:**\n\n   * Derive a clear, one-sentence value proposition from `README`’s Description/Overview.\n   * Collect 4–7 key capabilities/benefits (bullets for LinkedIn).\n\n5. **Tech stack:**\n\n   * From `README`, extract notable technologies (backend, frontend, infra/services).\n   * Examples to detect if present: Django, DRF, Celery, Redis, Channels/WebSockets, Next.js, React, TypeScript, Tailwind CSS, Zustand, Framer Motion, Stripe, OpenAI, OAuth/Google, SMTP/Email, Docker, Docker Compose.\n   * For **Twitter**, mention only the **3–4 most central** technologies.\n   * For **LinkedIn**, you may group by Backend / Frontend / Infra.\n\n## LinkedIn post (English, long-form)\n\n* Tone: professional, enthusiastic, concise sentences; **no emojis**.\n* Structure (use short paragraphs and bullet points):\n\n  * Hook:\n\n    * If first release → start with “New project: …” or similar phrasing.\n    * If update → start with “Updating the project \\[name]: …” or similar phrasing.\n  * What it does: 1 short paragraph.\n  * Key features/benefits: 4–7 bullets.\n  * Tech stack (grouped): bullets for Backend, Frontend, Infra/Services.\n  * Motivational developer line (one sentence, non-cheesy).\n  * Call to action with the **repo link** (exactly once).\n* Hashtags: **8–12** relevant tags, all lowercase, no spaces (use hyphens only if part of the tech brand). Prioritize technologies and domain, e.g.:\n  `#python #django #nextjs #typescript #tailwindcss #stripe #openai #celery #redis #websockets #ai #saas #startups #webdevelopment`\n  (Pick only those truly present; don’t invent.)\n\n## Twitter post (English, max 280 chars including link)\n\n* Format:\n\n  * If first release → short sentence like “New project: …” or similar.\n  * If update → short sentence like “Updating project \\[name]: …” or similar.\n* Describe what the app does + **repo link** (once).\n* Mention **3–4** main technologies inline (e.g., Django, Next.js, Stripe, OpenAI).\n* **2–3 hashtags max**, chosen from the most relevant.\n* **No emojis.**\n* Length enforcement: if >280 chars, iteratively shorten by (in order): remove adjectives, compress wording, then drop one hashtag at a time until ≤280. Never drop the repo link.\n\n## Output formatting\n\n* Return a **single JSON object** with keys `\"twitter\"` and `\"linkedin\"`.\n* Escape quotes properly.\n* Do **not** add explanations, markdown, or extra whitespace before/after the JSON.\n* Do not include any links other than the repo link.\n\n## Safety & accuracy\n\n* Never fabricate tech or features not present in the inputs.\n* If some sections are missing in inputs, omit that detail gracefully.\n* Keep everything in **English** except hashtags which are typically lowercase English tokens.\n* Do not output dates/releases unless explicitly present.\n* Maintain a positive, credible tone.\n"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "927afa09-65bf-4c62-955c-42a3bb098f28",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        832,
        80
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "9RjbvMHnwZg2LraO",
          "name": "OpenAi ROD"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "43f2f142-8319-445f-80a9-61c56ae6ddad",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1008,
        80
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"twitter\": \"tweet in English, <=280 chars including the GitHub link\",\n  \"linkedin\": \"LinkedIn post in English, long-form\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "c2454817-d07d-45e0-8c5f-03a68c619eb8",
      "name": "发布推文",
      "type": "n8n-nodes-base.twitter",
      "position": [
        1248,
        48
      ],
      "parameters": {
        "text": "={{ $json.output.twitter }}",
        "additionalFields": {}
      },
      "credentials": {
        "twitterOAuth2Api": {
          "id": "VF7lxb5r1ouC0O22",
          "name": "X account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "944f1559-f79e-4034-b70f-0246c8b40a5f",
      "name": "编辑字段8",
      "type": "n8n-nodes-base.linkedIn",
      "position": [
        1248,
        -160
      ],
      "parameters": {
        "text": "={{ $json.output.linkedin }}",
        "person": "nUdV-_cHkk",
        "additionalFields": {}
      },
      "credentials": {
        "linkedInOAuth2Api": {
          "id": "Slo13uTVYAdaV30t",
          "name": "LinkedIn account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d64cf42e-40b0-4db8-9748-774751840a14",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -720
      ],
      "parameters": {
        "width": 660,
        "height": 900,
        "content": "# GitHub 推送 → README 和 CHANGELOG 检查"
      },
      "typeVersion": 1
    },
    {
      "id": "b08176e7-283f-4ed3-8c54-c90daeb05d59",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        -720
      ],
      "parameters": {
        "color": 4,
        "width": 640,
        "height": 920,
        "content": "# GitHub → 提取 → 合并/聚合"
      },
      "typeVersion": 1
    },
    {
      "id": "90e42f76-4ca3-4e6d-902c-2b4f1e29c0a4",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -720
      ],
      "parameters": {
        "width": 720,
        "height": 920,
        "content": "# LLM → 发布到 Twitter 和 LinkedIn"
      },
      "typeVersion": 1
    },
    {
      "id": "3f31d48b-c0cc-4140-9bd8-02f4267f7f65",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -720
      ],
      "parameters": {
        "color": 5,
        "width": 780,
        "height": 900,
        "content": "# 从 GitHub 推送生成 Twitter 和 LinkedIn 社交帖子"
      },
      "typeVersion": 1
    },
    {
      "id": "95134ca6-76d8-49a2-ae2c-6f1d7121c9a6",
      "name": "从文件提取 README",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        224,
        -208
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "a61fd00a-34f2-4e8b-bdf5-7e9c686f58ed",
      "name": "从文件提取 CHANGELOG",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        224,
        32
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "78f3c247-4dc6-474b-8a51-3a55a072dd92",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Get CHANGELOG",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get README",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get README": {
      "main": [
        [
          {
            "node": "Extract from File README",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get CHANGELOG": {
      "main": [
        [
          {
            "node": "Extract from File CHANGELOG",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Post tweet",
            "type": "main",
            "index": 0
          },
          {
            "node": "LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File README": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File CHANGELOG": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量18
分类1
节点类型13
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Jorge Martínez

Jorge Martínez

@jorgemartinezjam

AI Engineer & Full Stack Developer skilled in designing intelligent agents, workflow automation, and NLP solutions. Experienced with LLMs, Relevance AI, make, zapier, and n8n. Proficient in integrating AI and chatbots into web apps, optimizing processes, and leveraging automation for real-time productivity. Strong background in backend and frontend development, REST APIs, and database management.

外部链接
在 n8n.io 查看

分享此工作流