Skip to content

Commit 6999160

Browse files
sounmindclaude
andcommitted
fix: 브랜치 이름에 run_id 추가하여 충돌 방지
- 같은 날 여러 번 실행 시 브랜치 이름 충돌 문제 수정 - README.md 문서화 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ec30955 commit 6999160

File tree

2 files changed

+135
-3
lines changed

2 files changed

+135
-3
lines changed

.github/workflows/match.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
run: |
4949
git config user.name "github-actions[bot]"
5050
git config user.email "github-actions[bot]@users.noreply.github.com"
51-
BRANCH_NAME="chore/update-match-history-$(date +%Y-%m-%d)"
51+
BRANCH_NAME="chore/update-match-history-$(date +%Y-%m-%d)-${{ github.run_id }}"
5252
git checkout -b "$BRANCH_NAME"
5353
git add data/history.json
5454
git diff --staged --quiet && exit 0

README.md

Lines changed: 134 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,134 @@
1-
# coffee
2-
커피챗
1+
# Coffee Chat ☕
2+
3+
디스코드 서버에서 커피챗 참여자를 자동으로 매칭해주는 봇입니다.
4+
5+
## 기능
6+
7+
- Discord Role 기반 참여자 자동 조회
8+
- 중복 방지 알고리즘으로 매칭 생성 (최근 4회 이력 확인)
9+
- Discord Webhook으로 매칭 결과 발표
10+
- GitHub Actions를 통한 격주 자동 실행
11+
- 매칭 이력 자동 PR 생성
12+
13+
## 설치 방법
14+
15+
### 1. Bun 설치
16+
17+
```bash
18+
curl -fsSL https://bun.sh/install | bash
19+
```
20+
21+
### 2. 의존성 설치
22+
23+
```bash
24+
bun install
25+
```
26+
27+
## 환경변수 설정
28+
29+
| 환경변수 | 설명 | 타입 |
30+
|---------|------|------|
31+
| `DISCORD_BOT_TOKEN` | Discord Bot 토큰 | Secret |
32+
| `DISCORD_WEBHOOK_URL` | Discord Webhook URL | Secret |
33+
| `DISCORD_SERVER_ID` | Discord 서버(Guild) ID | Variable |
34+
| `DISCORD_ROLE_ID` | 커피챗 참여자 Role ID | Variable |
35+
36+
### GitHub Actions 설정
37+
38+
1. Repository Settings > Secrets and variables > Actions
39+
2. **Secrets** 탭에서 추가:
40+
- `DISCORD_BOT_TOKEN`
41+
- `DISCORD_WEBHOOK_URL`
42+
3. **Variables** 탭에서 추가:
43+
- `DISCORD_SERVER_ID`
44+
- `DISCORD_ROLE_ID`
45+
46+
## Discord 봇 & Webhook 설정
47+
48+
### Bot 생성
49+
50+
1. [Discord Developer Portal](https://discord.com/developers/applications) 접속
51+
2. "New Application" 클릭하여 앱 생성
52+
3. Bot 메뉴에서 "Add Bot" 클릭
53+
4. "Reset Token"으로 토큰 발급 → `DISCORD_BOT_TOKEN`으로 사용
54+
55+
### Bot 권한 설정
56+
57+
1. Bot 메뉴 > Privileged Gateway Intents
58+
2. **SERVER MEMBERS INTENT** 활성화 (필수)
59+
3. OAuth2 > URL Generator에서 권한 설정:
60+
- Scopes: `bot`
61+
- Bot Permissions: `Read Messages/View Channels`
62+
4. 생성된 URL로 서버에 봇 초대
63+
64+
### Webhook 생성
65+
66+
1. Discord 서버 > 채널 설정 > 연동
67+
2. "웹후크 만들기" 클릭
68+
3. Webhook URL 복사 → `DISCORD_WEBHOOK_URL`로 사용
69+
70+
### ID 확인 방법
71+
72+
1. Discord 설정 > 고급 > 개발자 모드 활성화
73+
2. 서버 이름 우클릭 > "서버 ID 복사" → `DISCORD_SERVER_ID`
74+
3. 서버 설정 > 역할 > 역할 우클릭 > "역할 ID 복사" → `DISCORD_ROLE_ID`
75+
76+
## 사용 방법
77+
78+
### 로컬 실행
79+
80+
```bash
81+
# 환경변수 설정 후
82+
export DISCORD_BOT_TOKEN="your-token"
83+
export DISCORD_WEBHOOK_URL="your-webhook-url"
84+
export DISCORD_SERVER_ID="your-server-id"
85+
export DISCORD_ROLE_ID="your-role-id"
86+
87+
# 매칭 실행
88+
bun run match
89+
```
90+
91+
### GitHub Actions 자동 실행
92+
93+
- **스케줄**: 매주 월요일 UTC 00:00 (KST 09:00)
94+
- **격주 실행**: 짝수 주차에만 실행
95+
- 수동 실행 시에는 주차 상관없이 실행
96+
97+
### 수동 실행
98+
99+
```bash
100+
# GitHub CLI 사용
101+
gh workflow run match.yml
102+
103+
# 또는 GitHub 웹에서
104+
# Actions > Coffee Chat Matching > Run workflow
105+
```
106+
107+
## 실행 흐름
108+
109+
1. Discord API로 Role 기반 참여자 조회
110+
2. 매칭 이력 로드 (`data/history.json`)
111+
3. 중복 방지 알고리즘으로 매칭 생성
112+
4. `history.json`에 새 매칭 저장
113+
5. Discord Webhook으로 결과 발표
114+
6. 자동 PR 생성 (`chore/update-match-history-YYYY-MM-DD`)
115+
116+
## 개발
117+
118+
```bash
119+
# 테스트 실행
120+
bun test
121+
122+
# 린트 검사
123+
bun run lint
124+
125+
# 포맷팅
126+
bun run format
127+
128+
# 타입 체크
129+
bun run typecheck
130+
```
131+
132+
## 라이선스
133+
134+
MIT

0 commit comments

Comments
 (0)