π€ Issue Grooming #14
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
| # 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); |