Skip to content

Commit 0fc7ec8

Browse files
committed
ci: add management workflow
1 parent c10802e commit 0fc7ec8

File tree

1 file changed

+153
-0
lines changed

1 file changed

+153
-0
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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

Comments
Β (0)