GitHub / GitLab 노드 — 개발자 워크플로우 자동화
개발자의 하루는 코드 말고도 PR 리뷰 요청, 이슈 분류, 릴리스 노트 작성 같은 반복 업무로 가득하다. n8n을 연결하면 이 모든 것을 자동화할 수 있다.
GitHub Credential 설정
Personal Access Token (PAT)
- GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens
- "Generate new token" 클릭
- 필요한 권한 선택:
| 권한 | 용도 |
|---|---|
Contents: Read | 파일/커밋 읽기 |
Issues: Read & Write | 이슈 관리 |
Pull requests: Read & Write | PR 관리 |
Metadata: Read | 기본 정보 |
- n8n → Credentials → GitHub API → Access Token 입력
GitHub Trigger — 이벤트 감지
Webhook 방식 (권장)
GitHub 리포지토리의 Webhook을 n8n에 연결하면 실시간 이벤트 감지가 가능하다.
| 이벤트 | 트리거 시점 |
|---|---|
push | 코드가 푸시될 때 |
pull_request | PR 생성/수정/머지/닫기 |
issues | 이슈 생성/수정/닫기 |
release | 릴리스 생성/발행 |
star | 스타 추가/제거 |
workflow_run | GitHub Actions 완료 |
설정 방법
GitHub 리포지토리 → Settings → Webhooks → Add webhook:
Payload URL: https://n8n.example.com/webhook/github-events
Content type: application/json
Secret: (보안 키)
Events: "Let me select individual events" → 원하는 이벤트 선택
GitHub 노드 — 주요 동작
Issue 관리
Resource: Issue
Operations:
- Create: 이슈 생성
- Get: 특정 이슈 조회
- Update: 이슈 수정 (라벨, 담당자, 상태)
- Add Labels: 라벨 추가
- Remove Label: 라벨 제거
- Add Comment: 코멘트 추가
Pull Request 관리
Resource: Pull Request
Operations:
- Create: PR 생성
- Get: PR 상세 조회
- Update: PR 수정
- Merge: PR 머지
- Review: 리뷰 요청/승인
Repository 관리
Resource: Repository
Operations:
- Get: 리포 정보 조회
- List: 파일 목록
- Get File: 특정 파일 내용 조회
실전 1: PR 생성 → Slack 알림 + 리뷰어 배정
[Webhook: PR opened]
→ [Edit Fields: 정보 추출]
→ [GitHub: Add Reviewers]
→ [Slack: #code-review 채널 알림]
Webhook 데이터에서 추출
PR 제목: {{ $json.body.pull_request.title }}
작성자: {{ $json.body.pull_request.user.login }}
브랜치: {{ $json.body.pull_request.head.ref }} → {{ $json.body.pull_request.base.ref }}
URL: {{ $json.body.pull_request.html_url }}
변경 파일: {{ $json.body.pull_request.changed_files }}개
자동 리뷰어 배정
// Code 노드: 브랜치명으로 리뷰어 결정
const branch = $json.body.pull_request.head.ref;
let reviewers = [];
if (branch.startsWith('feat/')) {
reviewers = ['senior-dev', 'tech-lead'];
} else if (branch.startsWith('fix/')) {
reviewers = ['qa-engineer'];
} else if (branch.startsWith('docs/')) {
reviewers = ['tech-writer'];
}
return { json: { reviewers, ...($input.item.json) } };
Slack 메시지
🔀 *새 PR이 올라왔습니다!*
*제목:* {{ $json.title }}
*작성자:* {{ $json.author }}
*브랜치:* `{{ $json.branch }}`
*변경 파일:* {{ $json.changedFiles }}개
*리뷰어:* {{ $json.reviewers.join(', ') }}
<{{ $json.url }}|PR 보러가기>
실전 2: 이슈 본문 분석 → 자동 라벨링
[Webhook: Issues opened]
→ [Code: 키워드 분석]
→ [GitHub: Add Labels]
→ [GitHub: Add Comment]
키워드 기반 자동 라벨링
const title = $json.body.issue.title.toLowerCase();
const body = ($json.body.issue.body || '').toLowerCase();
const text = title + ' ' + body;
const labels = [];
const rules = {
'bug': ['버그', 'bug', 'error', '오류', '에러', 'crash'],
'enhancement': ['기능', 'feature', '개선', 'improve', '추가'],
'documentation': ['문서', 'docs', 'readme', '설명'],
'performance': ['성능', 'performance', '느림', 'slow', 'optimize'],
'security': ['보안', 'security', '취약점', 'vulnerability'],
'UI': ['ui', 'ux', '디자인', 'design', 'css', '화면']
};
for (const [label, keywords] of Object.entries(rules)) {
if (keywords.some(kw => text.includes(kw))) {
labels.push(label);
}
}
if (labels.length === 0) labels.push('triage');
return {
json: {
issueNumber: $json.body.issue.number,
labels,
owner: $json.body.repository.owner.login,
repo: $json.body.repository.name
}
};
자동 코멘트
👋 이슈를 등록해주셔서 감사합니다!
이 이슈에 자동으로 라벨이 추가되었습니다: {{ $json.labels.map(l => '`' + l + '`').join(', ') }}
담당자가 곧 확인할 예정입니다.
실전 3: 릴리스 자동 변경 로그
[Webhook: Release published]
→ [GitHub: List Commits (태그 간)]
→ [Code: 변경 로그 구성]
→ [Slack: 릴리스 알림]
→ [Notion: 릴리스 노트 저장]
GitLab 노드
GitLab 노드도 GitHub과 거의 동일한 구조다.
| 리소스 | 동작 |
|---|---|
| Issue | 생성, 조회, 수정, 코멘트 |
| Merge Request | 생성, 조회, 승인, 머지 |
| Repository | 파일 조회, 브랜치 관리 |
| Pipeline | 파이프라인 실행, 상태 조회 |
GitLab의 경우 Pipeline Trigger도 활용 가치가 높다:
[n8n Webhook: 배포 요청] → [GitLab: Trigger Pipeline] → [Wait: 파이프라인 완료]
→ [Slack: 배포 결과 알림]
📝 정리
- [x] GitHub Credential: Fine-grained PAT으로 최소 권한 설정
- [x] GitHub Trigger: Webhook으로 실시간 Push, PR, Issue 이벤트 감지
- [x] PR 자동화: 리뷰어 자동 배정, Slack 알림, 머지 자동화
- [x] 이슈 자동화: 키워드 기반 자동 라벨링, 자동 코멘트
- [x] GitLab: 동일한 패턴으로 MR, Pipeline 자동화 가능
다음 편 예고
19편: 파일 처리 — Google Drive, Dropbox, FTP 노드
파일 업로드, 다운로드, 변환, 동기화. Binary Data의 개념부터 실전 파일 파이프라인까지.