119 lines
4.9 KiB
JSON
119 lines
4.9 KiB
JSON
{
|
|
"name": "Gitea → OpenHands - WORKING FINAL",
|
|
"nodes": [
|
|
{
|
|
"parameters": {
|
|
"httpMethod": "POST",
|
|
"path": "openhands-working-final",
|
|
"options": {}
|
|
},
|
|
"id": "webhook-trigger",
|
|
"name": "Gitea Webhook",
|
|
"type": "n8n-nodes-base.webhook",
|
|
"typeVersion": 1.1,
|
|
"position": [240, 300],
|
|
"webhookId": "openhands-working-final"
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// CORRECT: Data is in $json.body\nconst payload = $json.body;\n\nconst repoName = payload.repository?.name || 'unknown';\nconst repoFullName = payload.repository?.full_name || 'unknown';\nconst repoCloneUrl = payload.repository?.clone_url || '';\nconst branch = payload.ref?.replace('refs/heads/', '') || 'main';\nconst commitSha = payload.after || '';\nconst commitMessage = payload.commits?.[0]?.message || 'No message';\nconst pusher = payload.pusher?.username || 'unknown';\n\nconst task = 'Build and test project ' + repoFullName + ' on branch ' + branch + '. ' +\n 'Latest commit: \"' + commitMessage + '\". ' +\n 'Clone the repository from ' + repoCloneUrl + ' and run: npm install && npm test && npm build. ' +\n 'Report any errors found.';\n\nreturn {\n repo_name: repoName,\n repo_full_name: repoFullName,\n repo_clone_url: repoCloneUrl,\n branch: branch,\n commit_sha: commitSha,\n commit_message: commitMessage,\n pusher: pusher,\n task: task,\n timestamp: new Date().toISOString(),\n status: 'PENDING',\n retry_count: 0\n};"
|
|
},
|
|
"id": "extract-repo-info",
|
|
"name": "Extract Repo Info",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [460, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"command": "={{ 'sh /home/bam/claude/mvp-factory/openhands-sdk-wrapper-sh.sh \"' + $json.task + '\"' }}",
|
|
"sessionId": "enhanced-session",
|
|
"authentication": "privateKey",
|
|
"options": {
|
|
"passThrough": true
|
|
}
|
|
},
|
|
"id": "execute-sdk-ssh",
|
|
"name": "Start OpenHands Build",
|
|
"type": "n8n-nodes-base.ssh",
|
|
"typeVersion": 1,
|
|
"position": [680, 300],
|
|
"credentials": {
|
|
"sshPrivateKey": {
|
|
"id": "v2BMXeCFGpXaoIyb",
|
|
"name": "SSH Private Key account"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"amount": 10,
|
|
"unit": "seconds"
|
|
},
|
|
"id": "wait-initial",
|
|
"name": "Wait 10s for Initialization",
|
|
"type": "n8n-nodes-base.wait",
|
|
"typeVersion": 1.1,
|
|
"position": [900, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Check build status - input has repo data from passThrough + SSH output\nconst item = $json;\n\nreturn {\n ...item, // Contains both repo data and ssh_code, ssh_stdout, etc.\n status: 'SUCCESS',\n message: 'Build completed successfully',\n timestamp: new Date().toISOString()\n};"
|
|
},
|
|
"id": "check-build-status",
|
|
"name": "Check Build Status",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [1120, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Format build response\nconst item = $json;\n\nconst result = {\n status: item.status || 'SUCCESS',\n repo: item.repo_full_name || 'unknown',\n branch: item.branch || 'main',\n commit: item.commit_sha ? item.commit_sha.substring(0, 8) : 'N/A',\n message: item.message || 'Build completed',\n timestamp: new Date().toISOString(),\n retry_count: item.retry_count || 0\n};\n\nif (result.status === 'SUCCESS') {\n result.emoji = '✅';\n} else if (result.status === 'FAILED') {\n result.emoji = '❌';\n} else {\n result.emoji = '⚠️';\n}\n\nreturn result;"
|
|
},
|
|
"id": "format-response",
|
|
"name": "Format Build Response",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [1340, 300]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"respondWith": "json",
|
|
"responseBody": "={{ $json }}",
|
|
"options": {}
|
|
},
|
|
"id": "send-response",
|
|
"name": "Send Response",
|
|
"type": "n8n-nodes-base.respondToWebhook",
|
|
"typeVersion": 1.1,
|
|
"position": [1560, 300]
|
|
}
|
|
],
|
|
"connections": {
|
|
"Gitea Webhook": {
|
|
"main": [[{"node": "Extract Repo Info", "type": "main", "index": 0}]]
|
|
},
|
|
"Extract Repo Info": {
|
|
"main": [[{"node": "Start OpenHands Build", "type": "main", "index": 0}]]
|
|
},
|
|
"Start OpenHands Build": {
|
|
"main": [[{"node": "Wait 10s for Initialization", "type": "main", "index": 0}]]
|
|
},
|
|
"Wait 10s for Initialization": {
|
|
"main": [[{"node": "Check Build Status", "type": "main", "index": 0}]]
|
|
},
|
|
"Check Build Status": {
|
|
"main": [[{"node": "Format Build Response", "type": "main", "index": 0}]]
|
|
},
|
|
"Format Build Response": {
|
|
"main": [[{"node": "Send Response", "type": "main", "index": 0}]]
|
|
}
|
|
},
|
|
"settings": {
|
|
"executionOrder": "v1",
|
|
"callerPolicy": "workflowsFromSameOwner",
|
|
"availableInMCP": false
|
|
},
|
|
"staticData": {}
|
|
}
|