PRμμ νλ‘μ νΈ Week μ€μ λλ½μ λ°©μ§λ₯Ό μν CI μ€μ #2
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: Project Week Check (Scheduled) π | ||
| on: | ||
| schedule: | ||
| # λ§€μΌ μ€μ 10μ, μ€ν 6μ (KST κΈ°μ€, UTCλ‘λ 1μ, 9μ) | ||
| - cron: '0 1,9 * * *' | ||
| workflow_dispatch: # μλ μ€ν | ||
| jobs: | ||
| check-all-prs: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write # λκΈ μμ± κΆν | ||
| 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' \ | ||
| | head -n 1) | ||
| if [ -z "$existing_comment" ]; then | ||
| # μ λκΈ μμ± | ||
| COMMENT_BODY="## β οΈ Week μ€μ μ΄ λλ½λμμ΅λλ€ | ||
| νλ‘μ νΈμμ Weekλ₯Ό μ€μ ν΄μ£ΌμΈμ! | ||
| ### μ€μ λ°©λ² | ||
| 1. PR μ°μΈ‘μ \`Projects\` μΉμ μμ \`리νΈμ½λ μ€ν°λ\` μ λλ‘λ€μ΄(βΌ) ν΄λ¦ | ||
| 2. νμ¬ μ£Όμ°¨λ₯Ό μ νν΄μ£ΌμΈμ (μ: \`Week 14(current)\` λλ \`Week 14\`) | ||
| π [μμΈν κ°μ΄λ 보기](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) | ||
| --- | ||
| π€ μ΄ λκΈμ GitHub Appμ ν΅ν΄ μλμΌλ‘ μμ±λμμ΅λλ€." | ||
| gh pr comment $pr_number \ | ||
| --repo ${{ github.repository }} \ | ||
| --body "$COMMENT_BODY" | ||
| echo " β λκΈ μμ± μλ£" | ||
| 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 | ||