|
1
|
name: Issue Triage |
|
2
|
|
|
3
|
on: |
|
4
|
issues: |
|
5
|
types: [opened] |
|
6
|
issue_comment: |
|
7
|
types: [created] |
|
8
|
workflow_dispatch: |
|
9
|
inputs: |
|
10
|
issue_number: |
|
11
|
description: 'Triage only this issue (e.g. 16247). Leave empty to triage every open issue.' |
|
12
|
required: false |
|
13
|
default: '' |
|
14
|
type: string |
|
15
|
skip_triaged: |
|
16
|
description: 'Skip issues that already have triage labels (type: bug, requires-more, requires-team, good first issue, help-wanted, feedback). Ignored when issue_number is set.' |
|
17
|
required: false |
|
18
|
default: true |
|
19
|
type: boolean |
|
20
|
|
|
21
|
jobs: |
|
22
|
# Runs only on workflow_dispatch: resolves which issues to triage. With |
|
23
|
# `issue_number` set it emits that single issue; otherwise it collects all |
|
24
|
# open non-bot issues for the matrix below. |
|
25
|
get-open-issues: |
|
26
|
if: github.event_name == 'workflow_dispatch' |
|
27
|
runs-on: ubuntu-latest |
|
28
|
permissions: |
|
29
|
issues: read |
|
30
|
outputs: |
|
31
|
matrix: ${{ steps.get-issues.outputs.matrix }} |
|
32
|
steps: |
|
33
|
- name: Get open issues |
|
34
|
id: get-issues |
|
35
|
env: |
|
36
|
GH_TOKEN: ${{ github.token }} |
|
37
|
ISSUE_NUMBER: ${{ inputs.issue_number }} |
|
38
|
SKIP_TRIAGED: ${{ inputs.skip_triaged }} |
|
39
|
run: | |
|
40
|
set -euo pipefail |
|
41
|
|
|
42
|
# Explicitly targeting one issue skips the label filter: the point of |
|
43
|
# naming an issue is to re-run triage on it regardless of its labels. |
|
44
|
if [[ -n "$ISSUE_NUMBER" ]]; then |
|
45
|
if ! [[ "$ISSUE_NUMBER" =~ ^[0-9]+$ ]]; then |
|
46
|
echo "::error::issue_number must be a positive integer, got '$ISSUE_NUMBER'" >&2 |
|
47
|
exit 1 |
|
48
|
fi |
|
49
|
echo "Triaging issue #$ISSUE_NUMBER only." |
|
50
|
echo "matrix=[{\"number\":$ISSUE_NUMBER}]" >> "$GITHUB_OUTPUT" |
|
51
|
exit 0 |
|
52
|
fi |
|
53
|
|
|
54
|
matrix=$(gh issue list --repo ${{ github.repository }} --state open --limit 500 --json number,author,labels \ |
|
55
|
--jq "[.[] | select( |
|
56
|
.author.is_bot == false and |
|
57
|
(if \"$SKIP_TRIAGED\" == \"true\" then |
|
58
|
([.labels[].name] | ( |
|
59
|
contains([\"type: bug\"]) or |
|
60
|
contains([\"requires-more\"]) or |
|
61
|
contains([\"requires-team\"]) or |
|
62
|
contains([\"good first issue\"]) or |
|
63
|
contains([\"help-wanted\"]) or |
|
64
|
contains([\"feedback\"]) |
|
65
|
)) | not |
|
66
|
else true end) |
|
67
|
) | {number: .number}]") |
|
68
|
|
|
69
|
echo "matrix=$matrix" >> "$GITHUB_OUTPUT" |
|
70
|
|
|
71
|
# Runs on workflow_dispatch: triages every open issue in parallel |
|
72
|
triage-all: |
|
73
|
needs: get-open-issues |
|
74
|
if: needs.get-open-issues.outputs.matrix != '[]' && needs.get-open-issues.outputs.matrix != '' |
|
75
|
strategy: |
|
76
|
matrix: |
|
77
|
issue: ${{ fromJson(needs.get-open-issues.outputs.matrix) }} |
|
78
|
max-parallel: 5 |
|
79
|
fail-fast: false |
|
80
|
uses: ./.github/workflows/triage-issue-action.yml |
|
81
|
with: |
|
82
|
issue_number: '${{ matrix.issue.number }}' |
|
83
|
secrets: |
|
84
|
MEDUSA_APP_ID: ${{ secrets.MEDUSA_APP_ID }} |
|
85
|
MEDUSA_APP_PRIVATE_KEY: ${{ secrets.MEDUSA_APP_PRIVATE_KEY }} |
|
86
|
CLAUDE_CODE_API_TOKEN: ${{ secrets.CLAUDE_CODE_API_TOKEN }} |
|
87
|
|
|
88
|
# Runs on issues/issue_comment events: triages a single issue |
|
89
|
triage: |
|
90
|
if: | |
|
91
|
(github.event_name == 'issues' && |
|
92
|
github.event.issue.user.type != 'Bot') || |
|
93
|
(github.event_name == 'issue_comment' && |
|
94
|
github.event.issue.pull_request == null && |
|
95
|
github.event.comment.user.type != 'Bot' && |
|
96
|
contains(github.event.comment.body, '@medusajs-bot triage')) |
|
97
|
uses: ./.github/workflows/triage-issue-action.yml |
|
98
|
with: |
|
99
|
issue_number: '${{ github.event.issue.number }}' |
|
100
|
secrets: |
|
101
|
MEDUSA_APP_ID: ${{ secrets.MEDUSA_APP_ID }} |
|
102
|
MEDUSA_APP_PRIVATE_KEY: ${{ secrets.MEDUSA_APP_PRIVATE_KEY }} |
|
103
|
CLAUDE_CODE_API_TOKEN: ${{ secrets.CLAUDE_CODE_API_TOKEN }} |