-
Notifications
You must be signed in to change notification settings - Fork 1
214 lines (180 loc) Β· 8.18 KB
/
Copy pathissue-grooming.yml
File metadata and controls
214 lines (180 loc) Β· 8.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# GitHub Issue Grooming Automation for ADHDo Project
#
# This workflow automatically maintains issue hygiene by:
# - Closing completed issues based on codebase analysis
# - Creating tracking issues for major features
# - Updating stale issues
# - Improving issue labeling
name: π€ Issue Grooming
on:
schedule:
# Run weekly on Sundays at 12:00 UTC
- cron: '0 12 * * 0'
workflow_dispatch:
inputs:
mode:
description: 'Grooming mode'
required: true
default: 'analyze'
type: choice
options:
- analyze
- auto-update
- dry-run
create_pr:
description: 'Create PR with recommendations'
required: false
default: true
type: boolean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
issue-grooming:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: π Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for commit analysis
- name: π Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: π¦ Install dependencies
run: |
pip install requests structlog
- name: π€ Run issue grooming analysis
id: grooming
run: |
# Set mode based on input or default to analyze
MODE="${{ github.event.inputs.mode || 'analyze' }}"
echo "Running in mode: $MODE"
# Create reports directory
mkdir -p reports
# Set output filename with timestamp
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
OUTPUT_FILE="reports/issue_grooming_report_${TIMESTAMP}.md"
# Run the grooming script
if [ "$MODE" = "auto-update" ]; then
python scripts/github_issue_grooming.py \
--auto-update \
--output "$OUTPUT_FILE" \
--github-token "$GITHUB_TOKEN"
else
python scripts/github_issue_grooming.py \
--analyze-only \
--output "$OUTPUT_FILE" \
--github-token "$GITHUB_TOKEN"
fi
# Set outputs for next steps
echo "output_file=$OUTPUT_FILE" >> $GITHUB_OUTPUT
echo "mode=$MODE" >> $GITHUB_OUTPUT
# Extract summary statistics
if [ -f "$OUTPUT_FILE" ]; then
ISSUES_TO_CLOSE=$(grep -o "Issues to Close:.*[0-9]" "$OUTPUT_FILE" | grep -o "[0-9]" || echo "0")
ISSUES_TO_UPDATE=$(grep -o "Issues to Update:.*[0-9]" "$OUTPUT_FILE" | grep -o "[0-9]" || echo "0")
ISSUES_TO_CREATE=$(grep -o "Issues to Create:.*[0-9]" "$OUTPUT_FILE" | grep -o "[0-9]" || echo "0")
echo "issues_to_close=$ISSUES_TO_CLOSE" >> $GITHUB_OUTPUT
echo "issues_to_update=$ISSUES_TO_UPDATE" >> $GITHUB_OUTPUT
echo "issues_to_create=$ISSUES_TO_CREATE" >> $GITHUB_OUTPUT
fi
- name: π Create issue summary
if: always()
run: |
echo "## π€ Issue Grooming Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Mode:** ${{ steps.grooming.outputs.mode }}" >> $GITHUB_STEP_SUMMARY
echo "**Report:** ${{ steps.grooming.outputs.output_file }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Recommendations:**" >> $GITHUB_STEP_SUMMARY
echo "- Issues to Close: ${{ steps.grooming.outputs.issues_to_close || 0 }}" >> $GITHUB_STEP_SUMMARY
echo "- Issues to Update: ${{ steps.grooming.outputs.issues_to_update || 0 }}" >> $GITHUB_STEP_SUMMARY
echo "- Issues to Create: ${{ steps.grooming.outputs.issues_to_create || 0 }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f "${{ steps.grooming.outputs.output_file }}" ]; then
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary>View Full Report</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```markdown' >> $GITHUB_STEP_SUMMARY
head -n 50 "${{ steps.grooming.outputs.output_file }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
- name: π Create PR with recommendations
if: github.event.inputs.create_pr == 'true' && steps.grooming.outputs.mode == 'analyze'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "π€ Issue grooming recommendations"
title: "π€ Issue Grooming Report - ${{ github.run_number }}"
body: |
## π€ Automated Issue Grooming Report
This PR contains the latest issue grooming analysis and recommendations.
### Summary
- **Issues to Close:** ${{ steps.grooming.outputs.issues_to_close || 0 }}
- **Issues to Update:** ${{ steps.grooming.outputs.issues_to_update || 0 }}
- **Issues to Create:** ${{ steps.grooming.outputs.issues_to_create || 0 }}
### Report Location
π `${{ steps.grooming.outputs.output_file }}`
### Next Steps
1. Review the report file for detailed recommendations
2. Close completed issues as identified
3. Update stale issues with current status
4. Create new tracking issues as needed
5. Improve issue labeling for better organization
### Automation
To execute the safe recommendations automatically, run:
```bash
./scripts/run_issue_grooming.sh auto --token $GITHUB_TOKEN
```
---
*This PR was created automatically by the Issue Grooming workflow*
branch: issue-grooming/report-${{ github.run_number }}
delete-branch: true
- name: π¬ Comment on issues (auto-update mode)
if: steps.grooming.outputs.mode == 'auto-update'
run: |
echo "Auto-update mode completed. Check job logs for details of actions taken."
- name: π Upload report artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: issue-grooming-report-${{ github.run_number }}
path: ${{ steps.grooming.outputs.output_file }}
retention-days: 30
notify-completion:
runs-on: ubuntu-latest
needs: issue-grooming
if: always() && (needs.issue-grooming.outputs.issues_to_close > 0 || needs.issue-grooming.outputs.issues_to_update > 0)
steps:
- name: π’ Notify team
uses: actions/github-script@v6
with:
script: |
const mode = '${{ needs.issue-grooming.outputs.mode }}';
const issuesToClose = '${{ needs.issue-grooming.outputs.issues_to_close }}';
const issuesToUpdate = '${{ needs.issue-grooming.outputs.issues_to_update }}';
const issuesToCreate = '${{ needs.issue-grooming.outputs.issues_to_create }}';
// Create a discussion post about the grooming results
const discussionBody = `## π€ Weekly Issue Grooming Results
The automated issue grooming has completed analysis of our GitHub issues.
### Summary
- **Mode:** ${mode}
- **Issues to Close:** ${issuesToClose}
- **Issues to Update:** ${issuesToUpdate}
- **Issues to Create:** ${issuesToCreate}
### Actions Needed
${issuesToClose > 0 ? `- β
Review and close ${issuesToClose} completed issues` : ''}
${issuesToUpdate > 0 ? `- π Update ${issuesToUpdate} stale issues` : ''}
${issuesToCreate > 0 ? `- β Create ${issuesToCreate} new tracking issues` : ''}
### Next Steps
1. Review the full report in the workflow artifacts
2. ${mode === 'analyze' ? 'Consider running auto-update mode to execute safe recommendations' : 'Check the workflow logs for executed actions'}
3. Manually review any issues that need human judgment
*Report generated automatically on ${new Date().toISOString().split('T')[0]}*
`;
console.log('Issue grooming completed:', discussionBody);