Skip to content

Project validation

Project validation #1

Workflow file for this run

name: PR Check πŸ””
on:
schedule:
# 맀일 μ˜€μ „ 10μ‹œ, μ˜€ν›„ 6μ‹œ (KST κΈ°μ€€, UTCλ‘œλŠ” 1μ‹œ, 9μ‹œ)
- cron: "0 1,9 * * *"
workflow_dispatch:
pull_request:
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=""
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 https://dalestudy.daleseo.workers.dev \
-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 μ„€μ • λˆ„λ½ - λŒ“κΈ€ μž‘μ„± μ‹œλ„"
# GitHub App으둜 λŒ“κΈ€ μž‘μ„±
comment_json="{\"pr_number\":$pr_number,\"repo_owner\":\"$repo_owner\",\"repo_name\":\"$repo_name\",\"comment_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을 톡해 μžλ™μœΌλ‘œ μž‘μ„±λ˜μ—ˆμŠ΅λ‹ˆλ‹€.\"}"
comment_response=$(curl -s -X POST "$WORKER_URL/comment" \
-H "Content-Type: application/json" \
-d "$comment_json")
if echo "$comment_response" | jq -e '.success' > /dev/null 2>&1; then
echo " βœ… λŒ“κΈ€ μž‘μ„± μ™„λ£Œ"
else
echo " ❌ λŒ“κΈ€ μž‘μ„± μ‹€νŒ¨: $comment_response"
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