Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions github-actions/labeling/issue/lib/issue-labeling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export class IssueLabeling extends Labeling {
repoAreaLabels = new Map<string, string>();
/** The issue data fetched from Github. */
issueData?: components['schemas']['issue'];
/** Labels added during this run. */
private addedLabels: string[] = [];

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

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

override async addLabel(label: string) {
await super.addLabel(label);
this.addedLabels.push(label);
}

async runAutoLabeling() {
// Determine if the issue already has an area label, if it does we can exit early.
if (
Expand Down
8 changes: 7 additions & 1 deletion github-actions/labeling/issue/main.js

Large diffs are not rendered by default.

Loading