Claude Random Easy Fixes #1
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: "Claude Random Easy Fixes" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| issue_count: | |
| description: "Number of issues to pick and fix in parallel" | |
| required: false | |
| default: "1" | |
| type: string | |
| jobs: | |
| pick-issues: | |
| name: "Pick easy fix issues" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| outputs: | |
| matrix: ${{ steps.pick-issues.outputs.matrix }} | |
| permissions: | |
| contents: read | |
| issues: read | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 | |
| with: | |
| egress-policy: audit | |
| - name: "Pick random Easy fix issues" | |
| id: pick-issues | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ISSUE_COUNT: ${{ inputs.issue_count || '1' }} | |
| run: | | |
| # Look up milestone number for "Easy fixes" | |
| MILESTONE_NUMBER=$(gh api "repos/phpstan/phpstan/milestones?per_page=100" \ | |
| --jq '.[] | select(.title == "Easy fixes") | .number') | |
| if [ -z "$MILESTONE_NUMBER" ]; then | |
| echo "Could not find 'Easy fixes' milestone" | |
| exit 1 | |
| fi | |
| # Fetch all open issues in the milestone using pagination | |
| ISSUE_JSON=$(gh api --paginate \ | |
| "repos/phpstan/phpstan/issues?state=open&milestone=${MILESTONE_NUMBER}&per_page=100" \ | |
| --jq '[.[] | {number: .number, title: .title}]' \ | |
| | jq -s 'add // []') | |
| TOTAL=$(echo "$ISSUE_JSON" | jq 'length') | |
| if [ "$TOTAL" -eq 0 ]; then | |
| echo "No issues found in Easy fixes milestone" | |
| exit 1 | |
| fi | |
| COUNT=$ISSUE_COUNT | |
| if [ "$COUNT" -gt "$TOTAL" ]; then | |
| COUNT=$TOTAL | |
| fi | |
| # Pick COUNT random unique issues | |
| SELECTED=$(echo "$ISSUE_JSON" | python3 -c " | |
| import json, sys, random | |
| issues = json.load(sys.stdin) | |
| random.shuffle(issues) | |
| count = min(int('$COUNT'), len(issues)) | |
| print(json.dumps(issues[:count])) | |
| ") | |
| echo "Selected $COUNT issue(s) for fixing" | |
| for NUMBER in $(echo "$SELECTED" | jq -r '.[].number'); do | |
| TITLE=$(echo "$SELECTED" | jq -r --argjson n "$NUMBER" '.[] | select(.number == $n) | .title') | |
| echo "### Selected issue: #$NUMBER - $TITLE" >> "$GITHUB_STEP_SUMMARY" | |
| done | |
| echo "matrix=$(echo "$SELECTED" | jq -c '.')" >> "$GITHUB_OUTPUT" | |
| easy-fix: | |
| name: "Fix #${{ matrix.issue.number }}: ${{ matrix.issue.title }}" | |
| needs: pick-issues | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| issue: ${{ fromJson(needs.pick-issues.outputs.matrix) }} | |
| uses: ./.github/workflows/claude-fix-issue.yml | |
| with: | |
| issue-number: ${{ matrix.issue.number }} | |
| secrets: inherit |