1+ name : Prioritize Issues by Reactions
2+
3+ on :
4+ # schedule:
5+ # - cron: '0 */4 * * *' # Runs every 4 hours
6+ workflow_dispatch : # Allows manual runs
7+
8+ jobs :
9+ prioritize :
10+ permissions :
11+ issues : write
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - name : Checkout repo
16+ uses : actions/checkout@v3
17+
18+ - name : Install jq
19+ run : sudo apt-get install -y jq
20+
21+ - name : Prioritize issues by reactions
22+ env :
23+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
24+ REPO : NuGet/Entropy // TODO Change this for the correct repo
25+ HIGH : 5
26+ MEDIUM : 2
27+ run : |
28+ issue_numbers=$(gh issue list -R "$REPO" --state open --json number -q '.[].number')
29+
30+ for ISSUE in $issue_numbers; do
31+ echo "🔍 Checking Issue #$ISSUE"
32+
33+ reactions=$(curl -s \
34+ -H "Accept: application/vnd.github.squirrel-girl-preview+json" \
35+ -H "Authorization: token $GH_TOKEN" \
36+ https://api.github.com/repos/$REPO/issues/$ISSUE/reactions)
37+
38+ total=$(echo "$reactions" | jq 'length')
39+
40+ if [ "$total" -ge "$HIGH" ]; then
41+ priority="p/0"
42+ elif [ "$total" -ge "$MEDIUM" ]; then
43+ priority="p/1"
44+ else
45+ priority="p/2"
46+ fi
47+
48+ echo "👉 Issue #$ISSUE has $total reactions — Assigning label: $priority"
49+
50+ # Get current p/* label (if any)
51+ current_priority=$(gh issue view $ISSUE -R $REPO --json labels -q '.labels[].name' | grep '^p/' || echo "")
52+
53+ if [[ "$current_priority" != "$priority" ]]; then
54+ if [[ -n "$current_priority" ]]; then
55+ echo " ⏹️ Removing old label: $current_priority"
56+ gh issue edit $ISSUE -R $REPO --remove-label "$current_priority"
57+ fi
58+
59+ echo " ➕ Adding new label: $priority"
60+ gh issue edit $ISSUE -R $REPO --add-label "$priority"
61+ else
62+ echo " ✅ Priority label already correct: $priority"
63+ fi
64+ echo ""
65+ done
0 commit comments