Skip to content

PRμ—μ„œ ν”„λ‘œμ νŠΈ Week μ„€μ • λˆ„λ½μ„ λ°©μ§€λ₯Ό μœ„ν•œ CI μ„€μ • #5

PRμ—μ„œ ν”„λ‘œμ νŠΈ Week μ„€μ • λˆ„λ½μ„ λ°©μ§€λ₯Ό μœ„ν•œ CI μ„€μ •

PRμ—μ„œ ν”„λ‘œμ νŠΈ Week μ„€μ • λˆ„λ½μ„ λ°©μ§€λ₯Ό μœ„ν•œ CI μ„€μ • #5

name: Project Week Check (Scheduled) πŸ””
on:
schedule:
# 맀일 μ˜€μ „ 10μ‹œ, μ˜€ν›„ 6μ‹œ (KST κΈ°μ€€, UTCλ‘œλŠ” 1μ‹œ, 9μ‹œ)
- cron: "0 1,9 * * *"
pull_request:
types: [opened, reopened, synchronize, edited, labeled, unlabeled]
workflow_dispatch: # μˆ˜λ™ μ‹€ν–‰
jobs:
check-all-prs:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write # PR λŒ“κΈ€ μž‘μ„± κΆŒν•œ
pull-requests: write # PR 정보 읽기 κΆŒν•œ
steps:
- name: Get all open PRs
id: get-prs
run: |
echo "πŸ“‹ Open PR λͺ©λ‘ 쑰회 쀑..."
prs=$(gh pr list \
--repo ${{ github.repository }} \
--state open \
--json number,labels \
--limit 100)
echo "prs=$prs" >> $GITHUB_OUTPUT
echo "Open PR 수: $(echo $prs | jq 'length')"
env:
GH_TOKEN: ${{ github.token }}
- name: Check Week settings for all PRs
run: |
prs='${{ steps.get-prs.outputs.prs }}'
WORKER_URL="https://dalestudy.daleseo.workers.dev"
repo_owner="${{ github.repository_owner }}"
repo_name="${{ github.event.repository.name }}"
echo "$prs" | jq -c '.[]' | while read -r pr; do
pr_number=$(echo $pr | jq -r '.number')
labels=$(echo $pr | jq -r '.labels[].name' | tr '\n' ',')
# maintenance 라벨이 있으면 μŠ€ν‚΅
if echo "$labels" | grep -q "maintenance"; then
echo "⏭️ PR #$pr_number: maintenance 라벨 - μŠ€ν‚΅"
continue
fi
echo ""
echo "πŸ” PR #$pr_number 검사 쀑..."
# GitHub App으둜 Week μ„€μ • 확인
response=$(curl -s -X POST "$WORKER_URL" \
-H "Content-Type: application/json" \
-d "{\"pr_number\": $pr_number, \"repo_owner\": \"$repo_owner\", \"repo_name\": \"$repo_name\"}")
week=$(echo $response | jq -r '.week')
project_found=$(echo $response | jq -r '.project_found')
echo " Week: $week"
echo " Project found: $project_found"
# Week 섀정이 μ—†μœΌλ©΄ λŒ“κΈ€ μž‘μ„±
if [ "$week" = "null" ] || [ -z "$week" ]; then
echo " ⚠️ Week μ„€μ • λˆ„λ½ - λŒ“κΈ€ μž‘μ„± μ‹œλ„"
# 이미 봇이 λŒ“κΈ€μ„ λ‹¬μ•˜λŠ”μ§€ 확인 (μ—λŸ¬ λ°œμƒ μ‹œ λ¬΄μ‹œ)
existing_comment=$(gh pr view $pr_number \
--repo ${{ github.repository }} \
--json comments \
--jq '.comments[] | select(.author.login == "github-actions[bot]") | select(.body | contains("Week 섀정이 λˆ„λ½")) | .id' \
2>/dev/null | head -n 1) || true
if [ -z "$existing_comment" ]; then
# μƒˆ λŒ“κΈ€ μž‘μ„±
if gh pr comment $pr_number \
--repo ${{ github.repository }} \
--body $'## ⚠️ Week 섀정이 λˆ„λ½λ˜μ—ˆμŠ΅λ‹ˆλ‹€\n\nν”„λ‘œμ νŠΈμ—μ„œ Weekλ₯Ό μ„€μ •ν•΄μ£Όμ„Έμš”!\n\n### μ„€μ • 방법\n1. PR 우츑의 `Projects` μ„Ήμ…˜μ—μ„œ `λ¦¬νŠΈμ½”λ“œ μŠ€ν„°λ””` μ˜† λ“œλ‘­λ‹€μš΄(β–Ό) 클릭\n2. ν˜„μž¬ μ£Όμ°¨λ₯Ό μ„ νƒν•΄μ£Όμ„Έμš” (예: `Week 14(current)` λ˜λŠ” `Week 14`)\n\nπŸ“š [μžμ„Έν•œ κ°€μ΄λ“œ 보기](https://github.com/DaleStudy/leetcode-study/wiki/%EB%8B%B5%EC%95%88-%EC%A0%9C%EC%B6%9C-%EA%B0%80%EC%9D%B4%EB%93%9C#pr-%EC%9E%91%EC%84%B1%EB%B2%95)\n\n---\nπŸ€– 이 λŒ“κΈ€μ€ GitHub App을 톡해 μžλ™μœΌλ‘œ μž‘μ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€.' 2>/dev/null; then
echo " βœ… λŒ“κΈ€ μž‘μ„± μ™„λ£Œ"
else
echo " ❌ λŒ“κΈ€ μž‘μ„± μ‹€νŒ¨ (κΆŒν•œ 문제 κ°€λŠ₯μ„±)"
fi
else
echo " ℹ️ 이미 μ•Œλ¦Ό λŒ“κΈ€μ΄ 있음 - μŠ€ν‚΅"
fi
else
echo " βœ… Week μ„€μ • 정상: $week"
fi
done
env:
GH_TOKEN: ${{ github.token }}
- name: Summary
run: |
echo "## 🎯 Week μ„€μ • 체크 μ™„λ£Œ" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "λͺ¨λ“  Open PR의 Week 섀정을 ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Week 섀정이 μ—†λŠ” PR에 μžλ™μœΌλ‘œ λŒ“κΈ€μ„ μž‘μ„±ν–ˆμŠ΅λ‹ˆλ‹€." >> $GITHUB_STEP_SUMMARY
echo "- λ‹€μŒ 체크: $(date -u -d '+1 hour' +'%Y-%m-%d %H:00 UTC')" >> $GITHUB_STEP_SUMMARY