
GitHub Dependabot pre-commit 훅 지원이란?
2026년 3월 10일, GitHub이 개발자들에게 오랫동안 기다려온 기능을 드디어 공개했습니다. Dependabot이 이제 pre-commit 훅의 자동 업데이트를 공식 지원합니다! 그동안 Python 패키지, npm 라이브러리, GitHub Actions의 의존성은 자동으로 관리할 수 있었지만, .pre-commit-config.yaml의 훅 버전은 수동으로 업데이트해야 했습니다. 이 불편함이 드디어 해소됩니다.

1. pre-commit이란? 왜 중요한가?
pre-commit은 Git 커밋 직전에 자동으로 코드 품질 검사를 실행하는 도구입니다. 린팅(linting), 포맷팅, 보안 취약점 검사 등 다양한 훅(hook)을 등록해두면, 개발자가 실수로 나쁜 코드를 커밋하기 전에 자동으로 잡아줍니다.
# .pre-commit-config.yaml 예시
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.1
hooks:
- id: gitleaks # 시크릿 키 유출 방지!
문제는 이 훅들의 rev 값(버전)이 시간이 지나면 구버전이 된다는 것입니다. 보안 취약점이 수정된 새 버전이 나와도 수동으로 업데이트하지 않으면 모르고 지나칠 수 있습니다. Dependabot이 이를 자동으로 감지하고 PR을 열어줍니다.

2. Dependabot pre-commit 설정 방법

기본 설정
.github/dependabot.yml에 package-ecosystem: "pre-commit"을 추가하면 됩니다:
# .github/dependabot.yml
version: 2
updates:
# 기존 npm 의존성 업데이트
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
# 기존 GitHub Actions 업데이트
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# ✨ 새로 추가! pre-commit 훅 자동 업데이트
- package-ecosystem: "pre-commit"
directory: "/" # .pre-commit-config.yaml이 있는 경로
schedule:
interval: "weekly" # 또는 "daily", "monthly"
고급 설정 — 그룹 업데이트
여러 훅을 한 번의 PR로 묶어서 업데이트할 수 있습니다:
# .github/dependabot.yml (그룹 업데이트)
version: 2
updates:
- package-ecosystem: "pre-commit"
directory: "/"
schedule:
interval: "weekly"
groups:
# 모든 pre-commit 훅을 하나의 PR로 묶기
all-pre-commit-hooks:
patterns:
- "*"
# 또는 보안 관련 훅만 따로 묶기
security-hooks:
patterns:
- "gitleaks"
- "detect-secrets"
- "bandit"
PR 자동 병합 설정 (GitHub Actions 연동)
# .github/workflows/auto-merge-dependabot.yml
name: Auto-merge Dependabot PRs
on:
pull_request:
types: [opened, synchronize]
jobs:
auto-merge:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Dependabot metadata
id: meta
uses: dependabot/fetch-metadata@v2
- name: Auto-merge pre-commit updates
# patch/minor 버전은 자동 병합
if: |
steps.meta.outputs.package-ecosystem == 'pre-commit' &&
(steps.meta.outputs.update-type == 'version-update:semver-patch' ||
steps.meta.outputs.update-type == 'version-update:semver-minor')
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3. Dependabot pre-commit 지원 기능 상세
Tag 및 SHA 기반 버전 지원
pre-commit 훅은 Git 태그 또는 커밋 SHA로 버전을 고정합니다. Dependabot은 두 방식 모두 지원합니다:
repos:
# ✅ 태그 기반 (일반적)
- repo: https://github.com/psf/black
rev: 24.10.0 ← Dependabot이 새 태그로 자동 업데이트
# ✅ SHA 기반 (보안 강화)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 2c64da4578cc3bc5bdc3e31b5d23a40fa5a4c52e ← SHA도 자동 업데이트
변경 로그 자동 포함
Dependabot이 열어주는 PR에는 해당 훅의 변경 로그(Changelog)와 릴리즈 노트가 자동으로 포함됩니다. 업데이트 전에 무엇이 바뀌었는지 확인하고 병합할 수 있습니다.
YAML 포맷 보존
# 업데이트 전
- repo: https://github.com/psf/black
rev: 24.8.0 # frozen: 24.8.0
hooks:
- id: black
# 업데이트 후 (Dependabot PR)
- repo: https://github.com/psf/black
rev: 24.10.0 # frozen: 24.10.0 ← 인라인 주석도 함께 업데이트!
hooks:
- id: black
멀티 호스트 지원
GitHub뿐 아니라 GitLab, Bitbucket 등 다양한 Git 호스팅에서 가져온 훅도 자동 업데이트됩니다.
4. GitHub REST API 2026-03-10 주요 변경 사항
같은 날 GitHub은 REST API의 새 캘린더 버전 2026-03-10도 공개했습니다. 이전 버전(2022-11-28) 이후 처음 Breaking Changes가 포함된 버전입니다.
API 버전 헤더 추가 방법
# curl 예시
curl -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer TOKEN" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/OWNER/REPO
# JavaScript (Octokit)
import { Octokit } from "@octokit/rest";
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
headers: {
"X-GitHub-Api-Version": "2026-03-10",
},
});
버전 업그레이드 가이드
- 기존 2022-11-28 버전은 최소 24개월 더 지원 (급하게 마이그레이션 불필요)
X-GitHub-Api-Version헤더 미포함 요청은 2022-11-28 기본값 유지- 새 버전으로 전환 시: GitHub 공식 Breaking Changes 문서 확인 후 테스트
5. 완전한 CI/CD 보안 파이프라인 구성하기
Dependabot pre-commit 지원을 활용한 완전 자동화된 코드 품질 파이프라인을 구성해봅시다:
# .github/workflows/code-quality.yml
name: Code Quality Pipeline
on:
push:
branches: [main, develop]
pull_request:
jobs:
pre-commit:
name: pre-commit 검사
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: pre-commit 실행
uses: pre-commit/action@v3.0.1
# 자동으로 최신 버전 사용 (Dependabot이 관리!)
security-scan:
name: 보안 취약점 스캔
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Gitleaks - 시크릿 스캔
uses: gitleaks/gitleaks-action@v2
- name: Trivy - 컨테이너 취약점 스캔
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
severity: 'CRITICAL,HIGH'
Dependabot 전체 의존성 관리 전략
2026년 기준, 완전한 Dependabot 설정으로 모든 의존성을 자동 관리하는 방법입니다:
# .github/dependabot.yml (완전한 설정)
version: 2
updates:
# npm/yarn/pnpm
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
# Python (pip/pip-compile)
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
# Docker 베이스 이미지
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "monthly"
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
# ✨ pre-commit 훅 (2026-03-10 신규!)
- package-ecosystem: "pre-commit"
directory: "/"
schedule:
interval: "weekly"
groups:
all-hooks:
patterns: ["*"]
Dependabot의 pre-commit 지원은 작은 기능처럼 보이지만, 개발 팀의 보안 위생(Security Hygiene) 유지에 큰 도움이 됩니다. 훅 버전이 최신 상태로 유지되면 알려진 취약점에 노출될 위험이 줄어들고, 수동 업데이트 작업도 사라집니다. GitHub REST API 2026-03-10 버전과 함께, 개발 워크플로우 자동화의 새 지평이 열리고 있습니다.