Skip to content

Commit 3307bfd

Browse files
committed
feat: add pr_state input to manual-pr-labeler workflow to support scanning closed and all PRs
1 parent ec939ea commit 3307bfd

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

.github/workflows/manual-pr-labeler.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@ on:
44
workflow_dispatch:
55
inputs:
66
pr_number:
7-
description: 'Specific PR number to label (leave blank to scan all open PRs)'
7+
description: 'Specific PR number to label (leave blank to scan PRs by state)'
88
required: false
99
type: string
10+
pr_state:
11+
description: 'State of PRs to scan (only used when PR number is blank)'
12+
required: false
13+
type: choice
14+
options:
15+
- open
16+
- closed
17+
- all
18+
default: open
1019
dry_run:
1120
description: 'Dry run (only print proposed labels without applying them)'
1221
required: false
@@ -33,6 +42,7 @@ jobs:
3342
const repo = context.repo.repo;
3443
3544
const prNumberInput = '${{ github.event.inputs.pr_number }}'.trim();
45+
const prStateInput = '${{ github.event.inputs.pr_state }}' || 'open';
3646
const dryRun = ${{ github.event.inputs.dry_run || 'false' }};
3747
3848
// Define the 10 label types, colors, and descriptions
@@ -93,18 +103,18 @@ jobs:
93103
return;
94104
}
95105
} else {
96-
console.log('🔍 Fetching all open PRs in repository...');
106+
console.log(`🔍 Fetching PRs with state "${prStateInput}" in repository...`);
97107
try {
98108
const { data } = await github.rest.pulls.list({
99109
owner,
100110
repo,
101-
state: 'open',
111+
state: prStateInput,
102112
per_page: 100
103113
});
104114
prs = data;
105-
console.log(` Found ${prs.length} open PR(s) to analyze.`);
115+
console.log(` Found ${prs.length} PR(s) with state "${prStateInput}" to analyze.`);
106116
} catch (err) {
107-
core.setFailed(`Failed to fetch open PRs: ${err.message}`);
117+
core.setFailed(`Failed to fetch PRs: ${err.message}`);
108118
return;
109119
}
110120
}

0 commit comments

Comments
 (0)