Skip to content

Commit 0505dc0

Browse files
committed
ci: 유저별 커밋 확인 로그 출력
1 parent 21bca1d commit 0505dc0

1 file changed

Lines changed: 63 additions & 20 deletions

File tree

.github/scripts/check_commits.py

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ def create_issue(github, repo, participant_name, date_str, penalty_type, amount)
106106
body=body,
107107
labels=labels
108108
)
109-
print(f"Issue 생성 완료: {issue.html_url}")
109+
print(f"✅ 완료 (Issue #{issue.number})")
110110
return issue
111111
except Exception as e:
112-
print(f"Issue 생성 중 오류 발생: {e}")
112+
print(f"❌ 실패: {e}")
113113
return None
114114

115115
def update_readme_penalty(participant_name, amount=5000):
@@ -133,10 +133,10 @@ def replace_amount(match):
133133
if new_content != content:
134134
with open(readme_path, 'w', encoding='utf-8') as f:
135135
f.write(new_content)
136-
print(f"README.md 업데이트 완료: {participant_name}님의 적립금 {amount}원 추가")
136+
# 로그는 호출하는 쪽에서 출력하므로 여기서는 출력하지 않음
137137
return True
138138
else:
139-
print(f"README.md 업데이트 실패: {participant_name}님을 찾을 수 없습니다.")
139+
print(f" 실패: {participant_name}님을 찾을 수 없습니다.")
140140
return False
141141

142142
except Exception as e:
@@ -168,12 +168,17 @@ def main():
168168
yesterday = today - timedelta(days=1)
169169
date_str = yesterday.strftime('%Y년 %m월 %d일')
170170

171-
print(f"=== {date_str} 커밋 확인 시작 ===")
171+
print(f"{'='*60}")
172+
print(f"📅 {date_str} 커밋 확인 시작")
173+
print(f"{'='*60}")
172174

173175
# 주말 체크 (평일만 확인)
174176
weekday = yesterday.weekday() # 0=월요일, 6=일요일
175177
if weekday >= 5: # 토요일(5) 또는 일요일(6)
176-
print(f"{date_str}는 주말입니다. 스터디 규칙에 따라 확인을 건너뜁니다.")
178+
weekday_name = "토요일" if weekday == 5 else "일요일"
179+
print(f"\nℹ️ {date_str}{weekday_name}입니다.")
180+
print(f" 스터디 규칙에 따라 확인을 건너뜁니다.")
181+
print(f"\n{'='*60}")
177182
return
178183

179184
# 어제 날짜의 시간 범위 (00:00:00 ~ 23:59:59)
@@ -189,24 +194,31 @@ def main():
189194
late_participants = [] # 어제 커밋이 없었는데 오늘 00:00~01:00 사이에 커밋한 사람들
190195

191196
# 각 참여자의 커밋 확인
192-
for name, github_username in PARTICIPANTS.items():
193-
print(f"\n{name} (@{github_username}) 확인 중...")
197+
print(f"\n📋 총 {len(PARTICIPANTS)}명의 참여자 커밋 확인 시작\n")
198+
199+
for idx, (name, github_username) in enumerate(PARTICIPANTS.items(), 1):
200+
print(f"[{idx}/{len(PARTICIPANTS)}] Checking {name} (@{github_username})...")
194201

195202
# 어제 커밋 확인
203+
print(f" → 어제 ({yesterday.strftime('%Y-%m-%d')}) 커밋 확인 중...", end=" ")
196204
has_yesterday_commit = check_user_commits(g, repo, github_username, yesterday_start, yesterday_end)
197205

198206
if not has_yesterday_commit:
199-
print(f"❌ {name}님의 어제 커밋이 확인되지 않았습니다.")
207+
print("❌ 없음")
200208
no_commit_participants.append(name)
201209

202210
# 오늘 00:00~01:00 사이에 커밋이 있는지 확인 (지각 체크)
211+
print(f" → 오늘 00:00~01:00 사이 커밋 확인 중...", end=" ")
203212
has_today_early_commit = check_user_commits(g, repo, github_username, today_start, today_01_00)
204213

205214
if has_today_early_commit:
206-
print(f"⏰ {name}님은 오늘 00:00~01:00 사이에 커밋을 완료했습니다. (지각)")
215+
print("✅ 있음 (지각)")
207216
late_participants.append(name)
217+
else:
218+
print("❌ 없음 (미제출)")
208219
else:
209-
print(f"✅ {name}님의 어제 커밋이 확인되었습니다.")
220+
print("✅ 있음")
221+
print(f" → 상태: 정상 완료")
210222

211223
# 처리할 참여자들
212224
penalty_participants = [] # 벌금 5000원 (어제 커밋 없음 + 오늘 00:00~01:00 사이에도 커밋 없음)
@@ -217,49 +229,80 @@ def main():
217229

218230
# 벌금 처리 (어제 커밋 없음 = 5000원)
219231
if penalty_participants:
220-
print(f"\n=== 미제출자 {len(penalty_participants)}명 발견 (벌금 5000원) ===")
232+
print(f"\n{'='*60}")
233+
print(f"⚠️ 미제출자 {len(penalty_participants)}명 발견 (벌금 5,000원)")
234+
print(f"{'='*60}")
221235

222236
for participant_name in penalty_participants:
237+
print(f"\n📌 처리 중: {participant_name}")
238+
print(f" → Issue 생성 중...", end=" ")
223239
# Issue 생성
224240
create_issue(g, repo, participant_name, date_str, 'no_commit', 5000)
225-
241+
print(f" → README.md 업데이트 중...", end=" ")
226242
# README.md 업데이트
227-
update_readme_penalty(participant_name, 5000)
243+
if update_readme_penalty(participant_name, 5000):
244+
print("✅ 완료")
245+
else:
246+
print("❌ 실패")
228247

229248
# 지각 처리 (어제 커밋 없음 + 오늘 00:00~01:00 사이 커밋 있음 = 3000원)
230249
if late_participants:
231-
print(f"\n=== 지각자 {len(late_participants)}명 발견 (지각 3000원) ===")
250+
print(f"\n{'='*60}")
251+
print(f"⏰ 지각자 {len(late_participants)}명 발견 (지각 3,000원)")
252+
print(f"{'='*60}")
232253

233254
for participant_name in late_participants:
255+
print(f"\n📌 처리 중: {participant_name}")
256+
print(f" → Issue 생성 중...", end=" ")
234257
# Issue 생성
235258
create_issue(g, repo, participant_name, date_str, 'late', 3000)
236-
259+
print(f" → README.md 업데이트 중...", end=" ")
237260
# README.md 업데이트
238-
update_readme_penalty(participant_name, 3000)
261+
if update_readme_penalty(participant_name, 3000):
262+
print("✅ 완료")
263+
else:
264+
print("❌ 실패")
239265

240266
# 변경사항 커밋
241267
if penalty_participants or late_participants:
268+
print(f"\n{'='*60}")
269+
print(f"💾 README.md 변경사항 커밋 중...")
270+
print(f"{'='*60}")
242271
try:
243272
import subprocess
273+
print(f" → Git 설정 중...", end=" ")
244274
subprocess.run(['git', 'config', 'user.name', 'github-actions[bot]'], check=True)
245275
subprocess.run(['git', 'config', 'user.email', 'github-actions[bot]@users.noreply.github.com'], check=True)
276+
print("✅ 완료")
277+
278+
print(f" → 파일 스테이징 중...", end=" ")
246279
subprocess.run(['git', 'add', 'README.md'], check=True)
280+
print("✅ 완료")
247281

248282
commit_message = f'[자동] {date_str} 누적 적립금 업데이트'
249283
if penalty_participants:
250284
commit_message += f' (미제출: {", ".join(penalty_participants)})'
251285
if late_participants:
252286
commit_message += f' (지각: {", ".join(late_participants)})'
253287

288+
print(f" → 커밋 생성 중...", end=" ")
254289
subprocess.run(['git', 'commit', '-m', commit_message], check=True)
290+
print("✅ 완료")
291+
292+
print(f" → 원격 저장소에 푸시 중...", end=" ")
255293
subprocess.run(['git', 'push'], check=True)
256-
print("\n✅ README.md 변경사항이 커밋되었습니다.")
294+
print("✅ 완료")
295+
print(f"\n✅ README.md 변경사항이 성공적으로 커밋되었습니다.")
257296
except Exception as e:
258297
print(f"\n⚠️ README.md 커밋 중 오류 발생: {e}")
259298
else:
260-
print("\n✅ 모든 참여자가 커밋을 완료했습니다!")
299+
print(f"\n{'='*60}")
300+
print(f"✅ 모든 참여자가 커밋을 완료했습니다!")
301+
print(f"{'='*60}")
261302

262-
print(f"\n=== {date_str} 커밋 확인 완료 ===")
303+
print(f"\n{'='*60}")
304+
print(f"🎉 {date_str} 커밋 확인 완료")
305+
print(f"{'='*60}")
263306

264307
if __name__ == '__main__':
265308
main()

0 commit comments

Comments
 (0)