Skip to content

Commit 7f484b1

Browse files
authored
Copy over community-contribution label from closing PR to issue (#37989)
1 parent 68bb873 commit 7f484b1

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/label-and-milestone-issues.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,26 @@ jobs:
152152
// (don't filter by state to avoid race conditions where GitHub
153153
// hasn't closed the issue yet when this workflow runs)
154154
const errors = [];
155+
const labelsToApply = [];
155156
if (label) {
157+
labelsToApply.push(label);
158+
}
159+
// If the PR has the community-contribution label, propagate it to closing issues
160+
if (context.payload.pull_request.labels.some(l => l.name === 'community-contribution')) {
161+
labelsToApply.push('community-contribution');
162+
}
163+
if (labelsToApply.length > 0) {
156164
for (const issue of closingIssues) {
157-
console.log(`Adding label '${label}' to issue #${issue.number}`);
165+
console.log(`Adding labels [${labelsToApply.join(', ')}] to issue #${issue.number}`);
158166
try {
159167
await github.rest.issues.addLabels({
160168
owner,
161169
repo,
162170
issue_number: issue.number,
163-
labels: [label]
171+
labels: labelsToApply
164172
});
165173
} catch (error) {
166-
errors.push(`Failed to add label to issue #${issue.number}: ${error.message}`);
174+
errors.push(`Failed to add labels to issue #${issue.number}: ${error.message}`);
167175
}
168176
}
169177
}
@@ -230,7 +238,7 @@ jobs:
230238
throw new Error(`Errors processing issues:\n${errors.join('\n')}`);
231239
}
232240
233-
console.log(`Done. Processed ${closingIssues.length} issue(s) with label '${label ?? 'none'}' and milestone '${targetMilestoneName}'`);
241+
console.log(`Done. Processed ${closingIssues.length} issue(s) with labels [${labelsToApply.join(', ') || 'none'}] and milestone '${targetMilestoneName}'`);
234242
235243
// Parses a milestone title as a semver version, or returns null for
236244
// non-version milestones (e.g. "Backlog", "MQ", "Discussions")

0 commit comments

Comments
 (0)