Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: process issues by tag label #301

Merged
merged 1 commit into from
Feb 28, 2024
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
1 change: 1 addition & 0 deletions VKUI/complete-publish/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ async function run(): Promise<void> {
const workflow = new WorkflowHandler(token, releaseTag);

await workflow.processReleaseNotes(latest === 'true');
await workflow.processIssuesByTagLabel();
await workflow.processMilestone();

if (workflow.isProcessWithError()) {
Expand Down
28 changes: 28 additions & 0 deletions VKUI/complete-publish/src/workflowHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ export class WorkflowHandler {
}
}

public async processIssuesByTagLabel() {
try {
const issueNumbers = await this.getIssueNumbersByTagLabel();

await this.commentOnIssues(issueNumbers);
} catch (error) {
if (error instanceof Error) {
core.error(error.message);
}
this.error = true;
}
}

public async processReleaseNotes(latest: boolean) {
try {
const releaseNotes = await this.findReleaseNotes();
Expand Down Expand Up @@ -115,6 +128,21 @@ export class WorkflowHandler {
}, []);
}

private async getIssueNumbersByTagLabel() {
const issues = await this.gh.paginate(this.gh.rest.issues.listForRepo, {
...github.context.repo,
state: 'all',
labels: this.releaseTag,
});

return issues.reduce<number[]>((issueNumbers, issue) => {
if (issue.state_reason !== IGNORED_STATE && !issue.locked) {
issueNumbers.push(issue.number);
}
return issueNumbers;
}, []);
}

private async commentOnIssues(issueNumbers: number[]) {
core.debug(`Processing the following linked issues: [${issueNumbers}]`);

Expand Down