183 lines
7.1 KiB
JSON
183 lines
7.1 KiB
JSON
{
|
|
"description": "n8n nodes for integrating with GitHub Actions workflow",
|
|
"nodes": [
|
|
{
|
|
"name": "Trigger GitHub Actions Build",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.1,
|
|
"position": [460, 300],
|
|
"parameters": {
|
|
"url": "https://api.github.com/repos/{{ $node['Extract Repo Info'].json.repo_owner }}/{{ $node['Extract Repo Info'].json.repo_name }}/actions/workflows/openhands-build.yml/dispatches",
|
|
"authentication": "predefinedCredentialType",
|
|
"nodeCredentialType": "githubApi",
|
|
"sendMethod": "POST",
|
|
"sendHeaders": true,
|
|
"headerParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "Accept",
|
|
"value": "application/vnd.github+json"
|
|
}
|
|
]
|
|
},
|
|
"sendBody": true,
|
|
"bodyParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "ref",
|
|
"value": "main"
|
|
},
|
|
{
|
|
"name": "inputs",
|
|
"value": "={{ JSON.stringify({ task: 'Build and test project: ' + $node['Extract Repo Info'].json.repo_name, workspace_path: '/workspace/' + $node['Extract Repo Info'].json.repo_name, retry_count: $workflow.staticData.retry_count || 0, project_type: 'nodejs' }) }}"
|
|
}
|
|
]
|
|
},
|
|
"options": {
|
|
"timeout": 30000
|
|
}
|
|
},
|
|
"notesInFlow": true,
|
|
"notes": "Triggers GitHub Actions workflow to build project using OpenHands SDK"
|
|
},
|
|
{
|
|
"name": "Wait for GitHub Actions",
|
|
"type": "n8n-nodes-base.wait",
|
|
"typeVersion": 2,
|
|
"position": [660, 300],
|
|
"parameters": {
|
|
"amount": 2,
|
|
"unit": "minutes",
|
|
"notesInFlow": true,
|
|
"notes": "Wait for GitHub Actions to complete (adjust timeout as needed)"
|
|
}
|
|
},
|
|
{
|
|
"name": "Check GitHub Actions Status",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.1,
|
|
"position": [860, 300],
|
|
"parameters": {
|
|
"url": "https://api.github.com/repos/{{ $node['Extract Repo Info'].json.repo_owner }}/{{ $node['Extract Repo Info'].json.repo_name }}/actions/runs/{{ $node['Trigger GitHub Actions Build'].json.data.id }}",
|
|
"authentication": "predefinedCredentialType",
|
|
"nodeCredentialType": "githubApi",
|
|
"sendMethod": "GET",
|
|
"sendQuery": true,
|
|
"queryParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "status",
|
|
"value": "completed"
|
|
}
|
|
]
|
|
},
|
|
"options": {
|
|
"timeout": 10000
|
|
}
|
|
},
|
|
"notesInFlow": true,
|
|
"notes": "Check if GitHub Actions workflow has completed"
|
|
},
|
|
{
|
|
"name": "Get Build Artifacts",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.1,
|
|
"position": [1060, 300],
|
|
"parameters": {
|
|
"url": "https://api.github.com/repos/{{ $node['Extract Repo Info'].json.repo_owner }}/{{ $node['Extract Repo Info'].json.repo_name }}/actions/runs/{{ $node['Trigger GitHub Actions Build'].json.data.id }}/artifacts",
|
|
"authentication": "predefinedCredentialType",
|
|
"nodeCredentialType": "githubApi",
|
|
"sendMethod": "GET",
|
|
"options": {
|
|
"timeout": 10000
|
|
}
|
|
},
|
|
"notesInFlow": true,
|
|
"notes": "Download build artifacts (logs, reports)"
|
|
},
|
|
{
|
|
"name": "Process GitHub Actions Result",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [1260, 300],
|
|
"parameters": {
|
|
"language": "javascript",
|
|
"jsCode": "// Get GitHub Actions result\nghRun = $node['Check GitHub Actions Status'].json;\nghArtifacts = $node['Get Build Artifacts'].json;\n\n// Extract build status\nconst status = ghRun.conclusion || ghRun.status;\nconst success = status === 'success';\n\n// Find build report artifact\nlet buildReport = null;\nif (ghArtifacts.artifacts) {\n const reportArtifact = ghArtifacts.artifacts.find(a => a.name.includes('build-report'));\n if (reportArtifact) {\n // In a real implementation, you'd download and parse the artifact\n // For now, we'll use the conclusion\n }\n}\n\n// Extract repository data\nconst repoData = $node['Extract Repo Info'].json;\n\n// Return combined result\nreturn {\n ...repoData,\n status: success ? 'SUCCESS' : 'FAILED',\n github_run_id: ghRun.id,\n github_run_url: ghRun.html_url,\n conclusion: ghRun.conclusion,\n conclusion_at: ghRun.updated_at,\n build_report: buildReport,\n retry_count: $workflow.staticData.retry_count || 0\n};"
|
|
},
|
|
"notesInFlow": true,
|
|
"notes": "Process GitHub Actions result and check build status"
|
|
},
|
|
{
|
|
"name": "Update Gitea Status (GitHub)",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.1,
|
|
"position": [1460, 300],
|
|
"parameters": {
|
|
"url": "https://git.oky.sh/api/v1/repos/{{ $node['Extract Repo Info'].json.repo_owner }}/{{ $node['Extract Repo Info'].json.repo_name }}/statuses/{{ $node['Extract Repo Info'].json.commit_sha }}",
|
|
"authentication": "predefinedCredentialType",
|
|
"nodeCredentialType": "giteaApi",
|
|
"sendMethod": "POST",
|
|
"sendBody": true,
|
|
"bodyParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "state",
|
|
"value": "={{ $json.status === 'SUCCESS' ? 'success' : 'failure' }}"
|
|
},
|
|
{
|
|
"name": "description",
|
|
"value": "Build {{ $json.status === 'SUCCESS' ? 'passed ✅' : 'failed ❌' }} via GitHub Actions (attempt #{{ $json.retry_count }})"
|
|
},
|
|
{
|
|
"name": "context",
|
|
"value": "openhands/github-actions"
|
|
},
|
|
{
|
|
"name": "target_url",
|
|
"value": "={{ $json.github_run_url }}"
|
|
}
|
|
]
|
|
},
|
|
"options": {
|
|
"timeout": 10000
|
|
}
|
|
},
|
|
"notesInFlow": true,
|
|
"notes": "Update Gitea commit status with GitHub Actions result"
|
|
}
|
|
],
|
|
"workflow_integration_steps": [
|
|
"1. Add 'Trigger GitHub Actions Build' node after 'Extract Repo Info'",
|
|
"2. Add 'Wait for GitHub Actions' node",
|
|
"3. Add 'Check GitHub Actions Status' node",
|
|
"4. Add 'Get Build Artifacts' node",
|
|
"5. Add 'Process GitHub Actions Result' node",
|
|
"6. Add 'Update Gitea Status (GitHub)' node",
|
|
"7. Configure GitHub credentials in n8n",
|
|
"8. Test workflow with a sample push"
|
|
],
|
|
"credential_setup": {
|
|
"github_api": {
|
|
"name": "GitHub API",
|
|
"type": "githubApi",
|
|
"data": {
|
|
"accessToken": "Your GitHub personal access token"
|
|
}
|
|
},
|
|
"gitea_api": {
|
|
"name": "Gitea API",
|
|
"type": "giteaApi",
|
|
"data": {
|
|
"accessToken": "Your Gitea API token"
|
|
}
|
|
}
|
|
},
|
|
"configuration_notes": [
|
|
"Create GitHub personal access token with 'repo' and 'workflow' permissions",
|
|
"Generate Gitea API token from user settings",
|
|
"Set repository name in environment variables",
|
|
"Adjust timeout values based on typical build duration",
|
|
"For long-running builds, consider implementing polling instead of fixed wait"
|
|
]
|
|
}
|