GitHub/GitLab Developer Automation
Chapter 12: GitHub / GitLab Developer Automation
Code repositories are the engineering team's central hub, but GitHub/GitLab notifications are noisy and siloed from collaboration tools. n8n bridges this gap with GitHub Trigger, GitLab Webhooks, and GitHub/GitLab action nodes. This chapter covers four core DevOps automation scenarios: PR auto-reviewer assignment, Issue-to-Notion sync, CI/CD status broadcasting, and overdue code review reminders.
GitHub Trigger: Listening to Repository Events
The GitHub Trigger node uses GitHub Webhooks for real-time event delivery. n8n automatically registers and removes the webhook when you activate/deactivate the workflow (requires a PAT with repo and admin:repo_hook scopes).
Key Event Types
| Event | When it fires | Common use |
|---|---|---|
| push | Code pushed to any branch | Deploy triggers, change alerts |
| pull_request | PR opened/updated/merged/closed | Auto-assign reviewers |
| pull_request_review | Review submitted (approved/changes_requested) | Notify PR author of review result |
| issues | Issue opened/edited/closed/labeled | Sync to Notion / task system |
| issue_comment | New comment on Issue or PR | @bot triggers workflow |
| workflow_run | GitHub Actions workflow completes | CI/CD status broadcast |
| release | New release published | Auto release notes, user notifications |
GitLab Webhook: MR Event Triggers
GitLab lacks a dedicated n8n Trigger node โ use a generic Webhook node instead. Copy the n8n Webhook URL into GitLab project Settings โ Webhooks, check the desired events (Merge Request, Pipeline, Issues), and optionally add a Secret Token. In n8n, validate the X-Gitlab-Token header in a Code node. Key MR payload fields: object_kind, object_attributes.state (opened/merged/closed), object_attributes.url.
Project: PR Created โ Auto-Assign Reviewer โ Feishu Notification
Workflow: GitHub Trigger (pull_request, action=opened) โ IF (skip bot PRs like dependabot) โ Code node (round-robin reviewer selection using Workflow Static Data) โ GitHub node (Request Review) โ HTTP Request (Feishu interactive card to reviewer with PR title, changed files count, and direct link).
// Feishu PR notification card body snippet
{
"msg_type": "interactive",
"card": {
"header": {
"title": { "tag": "plain_text", "content": "New PR Awaiting Your Review" },
"template": "blue"
},
"elements": [{
"tag": "action",
"actions": [{
"tag": "button",
"text": { "tag": "plain_text", "content": "Open PR" },
"type": "primary",
"url": "={{ $json.pull_request.html_url }}"
}]
}]
}
}
Project: Issue Closed โ Update Notion Task Status
GitHub Trigger (issues, filter action = "closed") โ Notion Get Many (find page where "GitHub Issue #" = {{ $json.issue.number }}) โ IF (page exists?) โ Notion Update Page (set Status = "Done", Closed At = now) โ optional Feishu notification to PM.
CI/CD Status Broadcast
GitHub Trigger (workflow_run, action = "completed") โ IF (branch is "main"?) โ Switch on conclusion (success / failure) โ HTTP Request to Feishu with green success card or red failure card (@oncall on failure).
// workflow_run event payload key fields
{
"action": "completed",
"workflow_run": {
"name": "CI",
"conclusion": "success",
"head_branch": "main",
"html_url": "https://github.com/org/repo/actions/runs/123"
}
}
Code Review Reminder: 24h Overdue Alert
Cron (hourly) โ GitHub node (List open PRs with requested reviewers) โ Code node (filter PRs older than 24h without a review) โ Loop Over Items โ HTTP Request (Feishu @reviewer reminder with PR title and wait duration).
Prevent reminder spam: Track already-notified PR IDs in Workflow Static Data. Check before sending โ skip any PR notified today to avoid hourly bombardment.