GitHub PR 深层链接与路由验证器 (n8n + ExecuteCommand + GitHub 评论)
初级
这是一个DevOps领域的自动化工作流,包含 5 个节点。主要使用 Set, Github, Webhook, Function, ExecuteCommand 等节点。 通过自动化测试验证 GitHub PR 中的移动应用深层链接
前置要求
- •GitHub Personal Access Token
- •HTTP Webhook 端点(n8n 会自动生成)
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "lasX9PkmCrv41JNs",
"meta": {
"instanceId": "14e4c77104722ab186539dfea5182e419aecc83d85963fe13f6de862c875ebfa",
"templateCredsSetupCompleted": true
},
"name": "GitHub PR 深层链接与路由验证器 (n8n + ExecuteCommand + GitHub 评论)",
"tags": [],
"nodes": [
{
"id": "e9665b03-2487-454a-8e9d-7f91d2a2d7bd",
"name": "GitHub PR Webhook",
"type": "n8n-nodes-base.webhook",
"position": [
-440,
20
],
"webhookId": "283c3a0f-15ca-4c8d-9440-6733d37d36a0",
"parameters": {
"path": "validate-pr",
"options": {},
"httpMethod": "POST",
"responseMode": "lastNode"
},
"typeVersion": 1
},
{
"id": "e58f11fb-8185-4964-9bfa-2b4b5422ee3a",
"name": "配置 - 变量",
"type": "n8n-nodes-base.set",
"position": [
-240,
20
],
"parameters": {
"values": {
"number": [
{
"name": "pullRequestNumber",
"value": 1
}
],
"string": [
{
"name": "repoUrl",
"value": ""
},
{
"name": "manifestPath",
"value": "deeplink-validator-demo/AndroidManifest.xml"
},
{
"name": "scriptPath",
"value": "deeplink-validator-demo/validate-links.sh"
},
{
"name": "commentMode",
"value": "replace"
},
{
"name": "timeout",
"value": "120"
},
{
"name": "githubToken",
"value": ""
},
{
"name": "branchName",
"value": "main"
},
{
"name": "repositoryFullName",
"value": "reponame"
}
]
},
"options": {}
},
"typeVersion": 1
},
{
"id": "ea82f4d2-26a6-4df3-8103-eb3e346541c1",
"name": "运行验证脚本",
"type": "n8n-nodes-base.executeCommand",
"position": [
-40,
20
],
"parameters": {
"command": "=#!/bin/sh\nrm -rf /tmp/validation\necho \"🔄 Cloning repo: {{ $json.repoUrl }}\"\ngit clone --depth 1 --branch \"{{ $json.branchName }}\" \"{{ $json.repoUrl }}\" /tmp/validation || exit 1\n\nSCRIPT_PATH=\"/tmp/validation/{{ $json.scriptPath }}\"\nMANIFEST_PATH=\"/tmp/validation/{{ $json.manifestPath }}\"\n\necho \"📁 Validating script path:\"\nls -l \"$SCRIPT_PATH\" || exit 1\n\nchmod +x \"$SCRIPT_PATH\" || exit 1\necho \"🚀 Executing: $SCRIPT_PATH $MANIFEST_PATH\"\nsh \"$SCRIPT_PATH\" \"$MANIFEST_PATH\" || {\n echo \"❌ Script execution failed\"\n exit 1\n}\necho \"✅ Script ran successfully\"\n"
},
"typeVersion": 1
},
{
"id": "76521f6f-e0d3-4ccf-84ae-ecb730979b2a",
"name": "格式化 Markdown",
"type": "n8n-nodes-base.function",
"position": [
160,
20
],
"parameters": {
"functionCode": "const lines = $node[\"Run Validation Script\"].json[\"stdout\"].split(\"\\n\");\nlet table = \"| Deep Link | Status |\\n|-----------|--------|\\n\";\nfor (const line of lines) {\n if (!line.includes(\",\")) continue;\n const [url, status] = line.split(\",\");\n if (!url || !status) continue;\n const icon = status.trim() === \"OK\" ? \"✅\" : \"❌\";\n table += `| ${url.trim()} | ${icon} ${status.trim()} |\\n`;\n}\nreturn [{ json: { markdownResult: table } }];"
},
"typeVersion": 1
},
{
"id": "32999f84-7453-48ba-8f5f-70251fd80335",
"name": "GitHub",
"type": "n8n-nodes-base.github",
"position": [
400,
20
],
"webhookId": "a12cc2e2-24ea-424b-8eeb-4264c4758d17",
"parameters": {
"body": "={{ $json.markdownResult }}",
"owner": {
"__rl": true,
"mode": "name",
"value": "={{ $('CONFIG - Variables').item.json.repositoryFullName.split(\"/\")[0] }}"
},
"operation": "createComment",
"repository": {
"__rl": true,
"mode": "name",
"value": "={{ $('CONFIG - Variables').item.json.repositoryFullName.split(\"/\")[1] }}"
},
"issueNumber": "={{ $('CONFIG - Variables').item.json.pullRequestNumber }}"
},
"credentials": {
"githubApi": {
"id": "Ryy6iiaCANDhpJC5",
"name": "GitHub account 3"
}
},
"typeVersion": 1.1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "8326daf3-a1ba-49b1-a392-4b1522a7f660",
"connections": {
"Format Markdown": {
"main": [
[
{
"node": "GitHub",
"type": "main",
"index": 0
}
]
]
},
"GitHub PR Webhook": {
"main": [
[
{
"node": "CONFIG - Variables",
"type": "main",
"index": 0
}
]
]
},
"CONFIG - Variables": {
"main": [
[
{
"node": "Run Validation Script",
"type": "main",
"index": 0
}
]
]
},
"Run Validation Script": {
"main": [
[
{
"node": "Format Markdown",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
初级 - 开发运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
物联网传感器数据清理器 + InfluxDB 记录器 (n8n | Webhook | Function | InfluxDB)
清理物联网传感器数据并记录到 InfluxDB (Webhook | Function | HTTP)
Set
Webhook
Function
+1
4 节点WeblineIndia
工程
自动生成发布说明
自动生成GitHub发布说明并通过Slack通知
Set
Code
Form Trigger
+2
10 节点WeblineIndia
开发运维
iOS环境配置同步向导:.env到Xcode
使用GitHub PR和邮件通知自动化iOS配置同步:.env到Xcode
Set
Code
Gmail
+3
12 节点WeblineIndia
开发运维
自动化视频上传 → 自动缩略图 → Google Drive
使用 FFmpeg 和 Google Drive 自动化视频上传和缩略图生成
If
Webhook
Google Drive
+5
9 节点WeblineIndia
内容创作
使用Robot Framework、ArgoCD和完整KinD生命周期实现自动化Kubernetes测试
基于 Robot Framework、ArgoCD 和完整 KinD 生命周期的自动化 Kubernetes 测试
If
Set
Gitlab
+10
73 节点Vigh Sandor
开发运维
工作流和凭据自动备份至GitHub(含变更检测)
工作流和凭据自动备份至GitHub(含变更检测)
If
Set
Crypto
+7
21 节点Hamed Nickmehr
开发运维
工作流信息
难度等级
初级
节点数量5
分类1
节点类型5
作者
WeblineIndia
@weblineindiaA Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.
外部链接
在 n8n.io 查看 →
分享此工作流