1name: "Labeler Backfill"
2
3on:
4 workflow_dispatch:
5 inputs:
6 target:
7 description: "What to backfill"
8 type: choice
9 default: both
10 options:
11 - issues
12 - prs
13 - both
14
15permissions:
16 issues: write
17 pull-requests: write
18 contents: read
19
20jobs:
21 issues:
22 if: github.event.inputs.target == 'issues' || github.event.inputs.target == 'both'
23 runs-on: ubuntu-latest
24 env:
25 GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
26 steps:
27 - name: Re-trigger issue labeler via no-op edit
28 run: |
29 set -euo pipefail
30 mapfile -t numbers < <(gh issue list --repo "$GITHUB_REPOSITORY" --state open --limit 1000 --json number -q '.[].number')
31 for n in "${numbers[@]}"; do
32 body=$(gh issue view "$n" --repo "$GITHUB_REPOSITORY" --json body -q .body)
33 # PATCH with same body → fires `edited` → labeler.yml runs
34 gh api -X PATCH "repos/$GITHUB_REPOSITORY/issues/$n" -f body="$body" >/dev/null
35 echo "touched #$n"
36 sleep 1
37 done
38
39 prs:
40 if: github.event.inputs.target == 'prs' || github.event.inputs.target == 'both'
41 runs-on: ubuntu-latest
42 env:
43 GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
44 steps:
45 - uses: actions/checkout@v7
46
47 - name: Collect open PR numbers
48 id: prs
49 run: |
50 nums=$(gh pr list --repo "$GITHUB_REPOSITORY" --state open --limit 1000 --json number -q '[.[].number] | join(",")')
51 echo "list=$nums" >> "$GITHUB_OUTPUT"
52
53 - name: Path labeler on open PRs
54 if: steps.prs.outputs.list != ''
55 uses: actions/labeler@v6
56 with:
57 repo-token: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
58 configuration-path: .github/pr-paths.yml
59 sync-labels: false
60 dot: true
61 pr-number: ${{ steps.prs.outputs.list }}
62
63 - name: Re-trigger text labeler on PRs via no-op edit
64 run: |
65 set -euo pipefail
66 mapfile -t numbers < <(gh pr list --repo "$GITHUB_REPOSITORY" --state open --limit 1000 --json number -q '.[].number')
67 for n in "${numbers[@]}"; do
68 body=$(gh pr view "$n" --repo "$GITHUB_REPOSITORY" --json body -q .body)
69 gh api -X PATCH "repos/$GITHUB_REPOSITORY/pulls/$n" -f body="$body" >/dev/null
70 echo "touched PR #$n"
71 sleep 1
72 done