Project validation #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |