✅ GitHub Actions로 라벨 자동 등록하기
📁 1. .github/workflows/create-labels.yml 생성
GITHUB_TOKEN → Personal Access Token (PAT) 사용
🛠 create-labels.yml (PAT 버전)
name: Create GitHub Labels
on:
workflow_dispatch:
push:
paths:
- .github/labels.json
jobs:
create-labels:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Create labels using GitHub API with PAT
env:
GH_PAT: ${{ secrets.MY_PAT }} # 👈 저장소 secret에 등록해야 함
run: |
LABELS_FILE=".github/labels.json"
echo "📦 Loading labels from $LABELS_FILE..."
cat "$LABELS_FILE"
jq -c '.[]' "$LABELS_FILE" | while read -r row; do
name=$(echo "$row" | jq -r '.name')
color=$(echo "$row" | jq -r '.color')
description=$(echo "$row" | jq -r '.description')
echo "👉 Creating: $name / $color / $description"
response=$(curl -s -X POST \
-H "Authorization: Bearer $GH_PAT" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/labels \
-d "{\"name\":\"$name\", \"color\":\"$color\", \"description\":\"$description\"}")
echo "🔍 GitHub API Response:"
echo "$response"
created=$(echo "$response" | jq -r '.name')
if [[ "$created" == "null" ]]; then
echo "❌ Failed to create label: $name"
else
echo "✅ Successfully created: $created"
fi
done
📁 2. .github/labels.json 생성
[
{ "name": "dev: in progress", "color": "1d76db", "description": "현재 작업 중인 항목" },
{ "name": "dev: blocked", "color": "cccccc", "description": "외부 요인으로 작업이 지연됨" },
{ "name": "dev: needs review", "color": "fbca04", "description": "코드 리뷰 또는 확인이 필요한 상태" },
{ "name": "dev: ready to merge", "color": "0e8a16", "description": "리뷰 완료, 머지 준비 완료" },
{ "name": "dev: done", "color": "006b75", "description": "작업 완료됨" },
{ "name": "dev: feature", "color": "84b6eb", "description": "신규 기능 개발" },
{ "name": "dev: bugfix", "color": "d73a4a", "description": "버그 수정 작업" },
{ "name": "dev: refactor", "color": "c2e0c6", "description": "코드 구조 개선 및 리팩토링" },
{ "name": "dev: optimization", "color": "fef2c0", "description": "성능 최적화 (FPS 향상, 메모리 개선 등)" },
{ "name": "dev: tech-debt", "color": "b60205", "description": "기술 부채 해결 작업" },
{ "name": "dev: unity", "color": "6f42c1", "description": "Unity 프로젝트 전체 구조, 설정, 씬 관리 등 범용 작업" },
{ "name": "dev: urp", "color": "c5def5", "description": "URP 렌더링 파이프라인 관련 작업 (Renderer Feature 등)" },
{ "name": "dev: shader", "color": "5319e7", "description": "셰이더 작성 및 수정 (HLSL/ShaderGraph 등)" },
{ "name": "dev: animation", "color": "fbca04", "description": "애니메이션 클립, 트랜지션, Animator 설정 등" },
{ "name": "dev: 3d-model", "color": "1abc9c", "description": "3D 모델링 관련 작업 또는 FBX 등 리소스 연동" },
{ "name": "dev: plugin", "color": "8b949e", "description": "외부 플러그인(Unity Asset Store 등) 연동 작업" },
{ "name": "dev: api", "color": "0366d6", "description": "API 연동 (서버 통신, 외부 데이터 요청 등)" },
{ "name": "dev: data", "color": "0e8a16", "description": "데이터 구조 정의, ScriptableObject, JSON 파싱 등" },
{ "name": "dev: voice", "color": "e99695", "description": "TTS, 음성 출력, 사운드 이벤트 등 음성 시스템 관련" },
{ "name": "dev: event-system", "color": "f9f2f4", "description": "UnityEvent, C# 이벤트, 버튼 클릭 처리 등" },
{ "name": "dev: ui-system", "color": "f7c6c7", "description": "UI 배치, Canvas, 버튼 및 Text 구성 등" },
{ "name": "qa: to test", "color": "fbca04", "description": "테스트 예정 항목 (기능 검증 필요)" },
{ "name": "qa: test passed", "color": "0e8a16", "description": "QA 또는 기능 테스트 통과" },
{ "name": "qa: test failed", "color": "d73a4a", "description": "테스트 실패 또는 이슈 발견" },
{ "name": "qa: feedback", "color": "cfd3d7", "description": "QA 피드백 반영 필요" }
]
✅ 사전 준비: secrets 등록
- GitHub → 저장소 → Settings → Secrets and variables > Actions
- New repository secret 클릭
- 이름: MY_PAT
- 값: 여기서 생성한 토큰 붙여넣기
- 권한: 최소 repo 체크 (또는 public_repo만)
https://github.com/settings/apps
GitHub · Build and ship software on a single, collaborative platform
Join the world's most widely adopted, AI-powered developer platform where millions of developers, businesses, and the largest open source community build software that advances humanity.
github.com
위에서 생성한 tokens 을 아래 Secret 안에 넣고 Add를 해줌
▶️ 실행 방법
- 위 두 파일을 .github/ 하위에 생성/커밋합니다.
- GitHub 웹 UI에서 Actions > Create GitHub Labels > Run workflow를 클릭하여 수동 실행하거나,
- labels.json을 변경 후 커밋하면 자동 실행됩니다.
"message": "Resource not accessible by personal access token",
"status": "403"
→ 이건 PAT 권한 설정 자체에 문제가 있다는 뜻입니다.
🔐 PAT 생성 시 권한 설정은 꼭 아래처럼:
만약 Classic token이라면
- 체크할 권한:
- ✅ repo
(이 안에 repo:status, repo_deployment, public_repo, repo:invite 등 포함되어 있음)
- ✅ repo
Fine-grained token이라면
- Repository access:
→ Only select repositories → 당신의 repo 선택 (JISUSAMA) - Repository permissions:
- ✅ Contents → Read and write
- ✅ (추가로 필요 시) Metadata 또는 Issues → Read-only (선택사항)
🔁 생성 후 다시 Secrets 등록
- 새 토큰 복사 → 저장소 Settings > Secrets > Actions
- MY_PAT secret을 다시 덮어쓰기 (같은 이름으로 저장하면 됨)
✅ 워크플로 다시 실행
지금 코드/스크립트는 완벽하므로
토큰 권한만 수정되면 201 Created로 성공 응답이 바뀝니다.
문제 해결
"403 by personal access token" | PAT의 권한이 부족함 |
해결 방법 | Contents: read/write 권한 포함해서 PAT 재생성 |
Secrets 갱신 | MY_PAT 덮어쓰기 |