Stale P3 Issue #17
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: Stale P3 Issue | |
| on: | |
| # Run weekly on Mondays before 9am Seattle time, so discussion needed labels are added before the working day. | |
| # Run at non-zero minute so we're not running at the same time as everyone else who runs at the zero minute. | |
| schedule: | |
| - cron: '29 15 * * 1' | |
| workflow_dispatch: | |
| inputs: | |
| batch_size: | |
| description: 'Number of issues to process per run' | |
| required: false | |
| default: '100' | |
| inactivity_days: | |
| description: 'Only process issues inactive for at least this many days (Default: 2 years)' | |
| required: false | |
| default: '730' # 730 days = 2 years, adjust as needed | |
| dry_run: | |
| description: 'Dry run (no changes made)' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| jobs: | |
| mark-stale-p3: | |
| permissions: | |
| issues: write | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| REPO: ${{ github.repository }} | |
| BATCH_SIZE: ${{ github.event.inputs.batch_size || '100' }} | |
| INACTIVITY_DAYS: ${{ github.event.inputs.inactivity_days || '730' }} | |
| DRY_RUN: ${{ github.event.inputs.dry_run || 'false' }} | |
| steps: | |
| - name: Mark stale P3 issues as inactive | |
| run: | | |
| echo "π Finding Priority:3 issues with <5 upvotes and no activity in $INACTIVITY_DAYS+ days..." | |
| echo "π¦ Batch size: $BATCH_SIZE" | |
| echo "π§ͺ Dry run: $DRY_RUN" | |
| echo "REPO: $REPO" | |
| echo "" | |
| # Validate numeric inputs | |
| if ! [[ "$BATCH_SIZE" =~ ^[0-9]+$ ]]; then | |
| echo "β Error: batch_size must be a positive integer, got: '$BATCH_SIZE'" | |
| exit 1 | |
| fi | |
| if ! [[ "$INACTIVITY_DAYS" =~ ^[0-9]+$ ]]; then | |
| echo "β Error: inactivity_days must be a positive integer, got: '$INACTIVITY_DAYS'" | |
| exit 1 | |
| fi | |
| CUTOFF_DATE=$(date -d "$INACTIVITY_DAYS days ago" -u +%Y-%m-%d) | |
| echo "β° Cutoff date: $CUTOFF_DATE" | |
| marked=0 | |
| echo "π Searching for Priority:3 issues with <5 reactions, last updated before $CUTOFF_DATE, without Status:Inactive" | |
| issues=$(gh search issues \ | |
| --repo "$REPO" \ | |
| --limit "$BATCH_SIZE" \ | |
| --json number \ | |
| --jq '.[].number' \ | |
| -- \ | |
| is:open \ | |
| label:Priority:3 \ | |
| -label:Status:Inactive \ | |
| reactions:\<5 \ | |
| updated:\<$CUTOFF_DATE \ | |
| sort:reactions-asc) | |
| if [ -z "$issues" ]; then | |
| echo "β No eligible P3 issues found." | |
| exit 0 | |
| fi | |
| total=$(echo "$issues" | wc -l | tr -d ' ') | |
| echo "π Found $total eligible issues to mark as inactive." | |
| echo "" | |
| for ISSUE in $issues; do | |
| if [ "$marked" -ge "$BATCH_SIZE" ]; then | |
| echo "π¦ Batch limit of $BATCH_SIZE reached." | |
| break | |
| fi | |
| if [ "$DRY_RUN" = "true" ]; then | |
| echo " π§ͺ [DRY RUN] Would mark Issue #$ISSUE as Status:Inactive" | |
| else | |
| echo " π·οΈ Marking Issue #$ISSUE as Status:Inactive" | |
| gh issue edit "$ISSUE" -R "$REPO" --add-label "Status:Inactive" | |
| fi | |
| marked=$((marked + 1)) | |
| echo "" | |
| # Small delay to avoid rate limiting | |
| sleep 1 | |
| done | |
| echo "================================" | |
| echo "β Done! Marked $marked issues as Status:Inactive." |