Skip to content

Commit 54e82b0

Browse files
thePunderWomanalan-agius4
authored andcommitted
fix(github-actions): fix issue with milestones not applying
Milestones have not been set properly with the issue triage github action. It is likely due to the api response happening too quickly after labels were applied, and not yet including them. So this manually accounts for the labels we added.
1 parent 2c2d7e6 commit 54e82b0

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

github-actions/labeling/issue/lib/issue-labeling.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export class IssueLabeling extends Labeling {
1414
repoAreaLabels = new Map<string, string>();
1515
/** The issue data fetched from Github. */
1616
issueData?: components['schemas']['issue'];
17+
/** Labels added during this run. */
18+
private addedLabels: string[] = [];
1719

1820
async run() {
1921
const {owner, repo, number} = context.issue;
@@ -35,6 +37,10 @@ export class IssueLabeling extends Labeling {
3537
const labels = updatedIssue.data.labels.map((l: string | {name?: string}) =>
3638
typeof l === 'string' ? l : l.name || '',
3739
);
40+
// the API response may not immediately reflect the labels we just added,
41+
// so we're adding the labels we've added during this run manually to ensure
42+
// the milestone logic below works correctly.
43+
labels.push(...this.addedLabels);
3844

3945
const hasAreaLabel = labels.some((l) => l.startsWith('area: '));
4046
const hasPriorityLabel = labels.some((l) => /^P[0-5]$/.test(l));
@@ -46,6 +52,11 @@ export class IssueLabeling extends Labeling {
4652
}
4753
}
4854

55+
override async addLabel(label: string) {
56+
await super.addLabel(label);
57+
this.addedLabels.push(label);
58+
}
59+
4960
async runAutoLabeling() {
5061
// Determine if the issue already has an area label, if it does we can exit early.
5162
if (

github-actions/labeling/issue/main.js

Lines changed: 7 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)