|
| 1 | +name: Management π§ |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + action: |
| 7 | + description: "Action to perform" |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + default: "approve-prs" |
| 11 | + options: |
| 12 | + - approve-prs |
| 13 | + - merge-prs |
| 14 | + exclude_prs: |
| 15 | + description: 'PR numbers to exclude (comma-separated, e.g., "1972,1973")' |
| 16 | + required: false |
| 17 | + type: string |
| 18 | + default: "" |
| 19 | + |
| 20 | +jobs: |
| 21 | + approve-prs: |
| 22 | + name: Approve Open PRs π |
| 23 | + runs-on: ubuntu-latest |
| 24 | + if: ${{ inputs.action == 'approve-prs' }} |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Approve PRs via GitHub App |
| 30 | + id: approve |
| 31 | + run: | |
| 32 | + echo "π GitHub Appμ ν΅ν΄ λͺ¨λ Open PR μΉμΈ μ€..." |
| 33 | +
|
| 34 | + # Parse exclude_prs input into JSON array |
| 35 | + exclude_input="${{ inputs.exclude_prs }}" |
| 36 | + if [ -z "$exclude_input" ]; then |
| 37 | + excludes="[]" |
| 38 | + else |
| 39 | + # Convert "1972,1973" to [1972,1973] |
| 40 | + excludes="[$(echo "$exclude_input" | sed 's/,/, /g')]" |
| 41 | + fi |
| 42 | +
|
| 43 | + echo "μ μΈν PR: $excludes" |
| 44 | +
|
| 45 | + response=$(curl -s -X POST "https://github.dalestudy.com/approve-prs" \ |
| 46 | + -H "Content-Type: application/json" \ |
| 47 | + -d "{\"repo_name\": \"${{ github.event.repository.name }}\", \"excludes\": $excludes}") |
| 48 | +
|
| 49 | + echo "response=$response" >> $GITHUB_OUTPUT |
| 50 | + echo "$response" | jq '.' |
| 51 | +
|
| 52 | + - name: Summary |
| 53 | + run: | |
| 54 | + response='${{ steps.approve.outputs.response }}' |
| 55 | +
|
| 56 | + success=$(echo "$response" | jq -r '.success // false') |
| 57 | + total=$(echo "$response" | jq -r '.total_open_prs // 0') |
| 58 | + processed=$(echo "$response" | jq -r '.processed // 0') |
| 59 | + approved=$(echo "$response" | jq -r '.approved // 0') |
| 60 | + skipped=$(echo "$response" | jq -r '.skipped // 0') |
| 61 | +
|
| 62 | + echo "## π PR μΉμΈ μλ£" >> $GITHUB_STEP_SUMMARY |
| 63 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 64 | +
|
| 65 | + if [ "$success" = "true" ]; then |
| 66 | + echo "β
**μ±κ³΅μ μΌλ‘ μλ£λμμ΅λλ€**" >> $GITHUB_STEP_SUMMARY |
| 67 | + else |
| 68 | + echo "β **μ€λ₯κ° λ°μνμ΅λλ€**" >> $GITHUB_STEP_SUMMARY |
| 69 | + fi |
| 70 | +
|
| 71 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 72 | + echo "- π μ 체 Open PR: **$total**κ°" >> $GITHUB_STEP_SUMMARY |
| 73 | + echo "- π κ²μ¬ν PR: **$processed**κ°" >> $GITHUB_STEP_SUMMARY |
| 74 | + echo "- β
μΉμΈν PR: **$approved**κ°" >> $GITHUB_STEP_SUMMARY |
| 75 | + echo "- βοΈ κ±΄λλ΄ PR: **$skipped**κ°" >> $GITHUB_STEP_SUMMARY |
| 76 | +
|
| 77 | + # Show detailed results if available |
| 78 | + results=$(echo "$response" | jq -r '.results // []') |
| 79 | + if [ "$results" != "[]" ]; then |
| 80 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 81 | + echo "### π μμΈ κ²°κ³Ό" >> $GITHUB_STEP_SUMMARY |
| 82 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 83 | + echo "$response" | jq -r '.results[] | "- PR #\(.pr_number): \(.status) \(if .reason then "(\(.reason))" else "" end)"' >> $GITHUB_STEP_SUMMARY |
| 84 | + fi |
| 85 | +
|
| 86 | + merge-prs: |
| 87 | + name: Merge Open PRs π |
| 88 | + runs-on: ubuntu-latest |
| 89 | + if: ${{ inputs.action == 'merge-prs' }} |
| 90 | + permissions: |
| 91 | + contents: read |
| 92 | + |
| 93 | + steps: |
| 94 | + - name: Merge PRs via GitHub App |
| 95 | + id: merge |
| 96 | + run: | |
| 97 | + echo "π GitHub Appμ ν΅ν΄ λͺ¨λ μΉμΈλ PR λ¨Έμ§ μ€..." |
| 98 | +
|
| 99 | + # Parse exclude_prs input into JSON array |
| 100 | + exclude_input="${{ inputs.exclude_prs }}" |
| 101 | + if [ -z "$exclude_input" ]; then |
| 102 | + excludes="[]" |
| 103 | + else |
| 104 | + # Convert "1972,1973" to [1972,1973] |
| 105 | + excludes="[$(echo "$exclude_input" | sed 's/,/, /g')]" |
| 106 | + fi |
| 107 | +
|
| 108 | + merge_method="merge" |
| 109 | + echo "λ¨Έμ§ λ°©μ: $merge_method" |
| 110 | + echo "μ μΈν PR: $excludes" |
| 111 | +
|
| 112 | + response=$(curl -s -X POST "https://github.dalestudy.com/merge-prs" \ |
| 113 | + -H "Content-Type: application/json" \ |
| 114 | + -d "{\"repo_name\": \"${{ github.event.repository.name }}\", \"merge_method\": \"$merge_method\", \"excludes\": $excludes}") |
| 115 | +
|
| 116 | + echo "response=$response" >> $GITHUB_OUTPUT |
| 117 | + echo "$response" | jq '.' |
| 118 | +
|
| 119 | + - name: Summary |
| 120 | + run: | |
| 121 | + response='${{ steps.merge.outputs.response }}' |
| 122 | +
|
| 123 | + success=$(echo "$response" | jq -r '.success // false') |
| 124 | + total=$(echo "$response" | jq -r '.total_open_prs // 0') |
| 125 | + processed=$(echo "$response" | jq -r '.processed // 0') |
| 126 | + merged=$(echo "$response" | jq -r '.merged // 0') |
| 127 | + skipped=$(echo "$response" | jq -r '.skipped // 0') |
| 128 | + merge_method=$(echo "$response" | jq -r '.merge_method // "unknown"') |
| 129 | +
|
| 130 | + echo "## π PR λ¨Έμ§ μλ£" >> $GITHUB_STEP_SUMMARY |
| 131 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 132 | +
|
| 133 | + if [ "$success" = "true" ]; then |
| 134 | + echo "β
**μ±κ³΅μ μΌλ‘ μλ£λμμ΅λλ€**" >> $GITHUB_STEP_SUMMARY |
| 135 | + else |
| 136 | + echo "β **μ€λ₯κ° λ°μνμ΅λλ€**" >> $GITHUB_STEP_SUMMARY |
| 137 | + fi |
| 138 | +
|
| 139 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 140 | + echo "- π§ λ¨Έμ§ λ°©μ: **$merge_method**" >> $GITHUB_STEP_SUMMARY |
| 141 | + echo "- π μ 체 Open PR: **$total**κ°" >> $GITHUB_STEP_SUMMARY |
| 142 | + echo "- π κ²μ¬ν PR: **$processed**κ°" >> $GITHUB_STEP_SUMMARY |
| 143 | + echo "- β
λ¨Έμ§ν PR: **$merged**κ°" >> $GITHUB_STEP_SUMMARY |
| 144 | + echo "- βοΈ κ±΄λλ΄ PR: **$skipped**κ°" >> $GITHUB_STEP_SUMMARY |
| 145 | +
|
| 146 | + # Show detailed results if available |
| 147 | + results=$(echo "$response" | jq -r '.results // []') |
| 148 | + if [ "$results" != "[]" ]; then |
| 149 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 150 | + echo "### π μμΈ κ²°κ³Ό" >> $GITHUB_STEP_SUMMARY |
| 151 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 152 | + echo "$response" | jq -r '.results[] | "- PR #\(.pr_number): \(.status) \(if .reason then "(\(.reason))" else "" end)"' >> $GITHUB_STEP_SUMMARY |
| 153 | + fi |
0 commit comments