Example Workflows (ready to adapt)
GitHub: Auto-Generate Documentation on Push
This workflow listens for pushes to your GitHub repository’s main branch, filters code files, generates Markdown documentation via the DocuWriter.ai node, commits the docs back to the repo, and notifies your team on Slack. It accelerates your CI process by keeping documentation in sync with code changes.
Workflow Diagram
flowchart TD
A[📌 GitHub Push Trigger] --> B[⚙️ Filter Main Branch]
B --> C[📂 List Repository Files]
C --> D[🗂️ Filter Code Files]
D --> E[📥 Get File Content]
E --> F[🛠️ Prepare Source Code]
F --> G[🤖 Generate Documentation]
G --> H[📝 Format Documentation]
H --> I[📦 Commit Documentation]
I --> J[🔔 Notify Team (Slack)]
Node Summary
| Step | Node ID | Type | Purpose |
|---|---|---|---|
| 1 | GitHub Push Trigger | n8n-nodes-base.githubTrigger | Listens for push events on owner/repository-name |
| 2 | Filter Main Branch | n8n-nodes-base.if | Only allow events where ref === refs/heads/main |
| 3 | List Repository Files | n8n-nodes-base.github | Retrieves all files in the repo (recursive) |
| 4 | Filter Code Files | n8n-nodes-base.code | Filters for .js/.ts/.py/.java/... and excludes node_modules, dist, build |
| 5 | Get File Content | n8n-nodes-base.github | Fetches base64-encoded content of each code file |
| 6 | Prepare Source Code | n8n-nodes-base.code | Decodes Base64 and packages sourceCode, filename, path for downstream nodes |
| 7 | Generate Documentation | n8n-nodes-docuwriter-ai.docuWriter | Calls DocuWriter.ai with resource=codeDocumentation to produce technical docs |
| 8 | Format Documentation | n8n-nodes-base.code | Wraps generated text in GitHub-friendly Markdown, defines output path (e.g. docs/*.md) |
| 9 | Commit Documentation | n8n-nodes-base.github | Commits the new/updated Markdown files back to main with message docs: auto-generate… |
| 10 | Notify Team | n8n-nodes-base.slack | Sends a Slack message summarizing file, path, and commit link to your #dev-team channel |
Example Node Definition
{
"name": "GitHub Auto-Documentation on Push",
"nodes": [
{
"id": "github-trigger",
"name": "GitHub Push Trigger",
"type": "n8n-nodes-base.githubTrigger",
"parameters": {
"authentication": "oAuth2",
"events": ["push"],
"repository": "owner/repository-name"
}
},
{
"id": "filter-main-branch",
"name": "Filter Main Branch",
"type": "n8n-nodes-base.if",
"parameters": {
"conditions": {
"string": [
{ "value1": "={{$json.ref}}", "operation": "equal", "value2": "refs/heads/main" }
]
}
}
},
{
"id": "list-repository-files",
"name": "List Repository Files",
"type": "n8n-nodes-base.github",
"parameters": {
"resource": "file",
"operation": "list",
"owner": "={{$json.repository.owner.login}}",
"repository": "={{$json.repository.name}}",
"additionalParameters": { "recursive": true }
}
},
{
"id": "filter-code-files",
"name": "Filter Code Files",
"type": "n8n-nodes-base.code",
"parameters": {
"jsCode": "// filters for .js, .ts, .py, etc."
}
},
{
"id": "get-file-content",
"name": "Get File Content",
"type": "n8n-nodes-base.github",
"parameters": {
"operation": "get",
"filePath": "={{$json.path}}"
}
},
{
"id": "prepare-source-code",
"name": "Prepare Source Code",
"type": "n8n-nodes-base.code",
"parameters": {
"jsCode": "// decode Base64 and set sourceCode, filename, path"
}
},
{
"id": "generate-documentation",
"name": "Generate Documentation",
"type": "n8n-nodes-docuwriter-ai.docuWriter",
"parameters": {
"resource": "codeDocumentation",
"operation": "generate",
"sourceCode": "={{$json.sourceCode}}",
"filename": "={{$json.filename}}",
"mode": "Accurate",
"outputLanguage": "English",
"documentationType": "Technical Documentation"
}
},
{
"id": "format-documentation",
"name": "Format Documentation",
"type": "n8n-nodes-base.code",
"parameters": {
"jsCode": "// wrap DocuWriter.ai output in Markdown, set docsPath"
}
},
{
"id": "commit-documentation",
"name": "Commit Documentation",
"type": "n8n-nodes-base.github",
"parameters": {
"operation": "create",
"filePath": "={{$json.docsPath}}",
"fileContent": "={{$json.content}}",
"commitMessage": "docs: auto-generate documentation for {{$json.filename}}",
"branch": "main"
}
},
{
"id": "notify-team",
"name": "Notify Team",
"type": "n8n-nodes-base.slack",
"parameters": {
"channel": "#dev-team",
"text": "📚 Documentation auto-generated for {{$node['format-documentation'].json.filename}}",
"attachments": [
{
"title": "{{$node['format-documentation'].json.filename}} Documentation",
"text": "Committed to docs/{{$node['format-documentation'].json.docsPath}}",
"actions": [
{ "type": "button", "text": "View Docs", "url": "={{$node['commit-documentation'].json.html_url}}" }
]
}
]
}
}
]
}
Excerpted and adapted from examples/workflows/github-auto-documentation.json
Benefits
- 🕒 Automated: Eliminates manual doc updates on every push.
- 🔍 Focused: Only processes code files, ignoring assets/binaries.
- 📦 Integrated: Commits docs back into
docs/folder, keeping code & docs together. - 🔔 Notified: Keeps your team informed via Slack with direct links.
Use this ready-to-adapt template to plug into your repo. Adjust file filters, branch names, or Slack channels to match your workflow.
Updated