feat: allow custom labels for new issues

This commit is contained in:
Aaron Kelbsch
2025-08-25 15:50:51 +02:00
parent d1a8548176
commit d8774e016c
4 changed files with 19 additions and 6 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+6 -1
View File
@@ -8,6 +8,7 @@ import { input } from '@clechasseur/rs-actions-core';
export interface Input {
token: string;
ignore: string[];
new_issue_labels: string[];
workingDirectory: string;
}
@@ -15,6 +16,10 @@ export function get(): Input {
return {
token: input.getInput('token', { required: true }),
ignore: input.getInputList('ignore', { required: false }),
workingDirectory: input.getInput('working-directory', { required: false }) ?? '.',
new_issue_labels: input.getInputList('new-issue-labels', {
required: false,
}),
workingDirectory:
input.getInput('working-directory', { required: false }) ?? '.',
};
}
+7 -1
View File
@@ -54,6 +54,7 @@ function removeTrailingSlash(str) {
}
export async function run(actionInput: input.Input): Promise<void> {
const labels = actionInput.new_issue_labels;
const ignore = actionInput.ignore;
const workingDirectory = removeTrailingSlash(actionInput.workingDirectory);
const report = await getData(ignore, workingDirectory);
@@ -97,7 +98,12 @@ export async function run(actionInput: input.Input): Promise<void> {
core.debug(
'Action was triggered on a schedule event, creating an Issues report',
);
await reporter.reportIssues(actionInput.token, advisories, warnings);
await reporter.reportIssues(
actionInput.token,
advisories,
warnings,
labels,
);
} else {
core.debug(
`Action was triggered on a ${github.context.eventName} event, creating a Check report`,
+5 -3
View File
@@ -166,7 +166,7 @@ export async function reportCheck(
vulnerabilities: Array<interfaces.Vulnerability>,
warnings: Array<interfaces.Warning>,
): Promise<void> {
const client = github.getOctokit(token, {userAgent: USER_AGENT});
const client = github.getOctokit(token, { userAgent: USER_AGENT });
const reporter = new checks.CheckReporter(client.rest, 'Security audit');
const stats = getStats(vulnerabilities, warnings);
const summary = getSummary(stats);
@@ -235,7 +235,7 @@ async function alreadyReported(
advisoryId: string,
): Promise<boolean> {
const { owner, repo } = github.context.repo;
const client = github.getOctokit(token, {userAgent: USER_AGENT});
const client = github.getOctokit(token, { userAgent: USER_AGENT });
const results = await client.rest.search.issuesAndPullRequests({
q: `${advisoryId} in:title repo:${owner}/${repo}`,
per_page: 1, // eslint-disable-line @typescript-eslint/camelcase
@@ -256,10 +256,11 @@ export async function reportIssues(
token: string,
vulnerabilities: Array<interfaces.Vulnerability>,
warnings: Array<interfaces.Warning>,
labels: string[],
): Promise<void> {
const { owner, repo } = github.context.repo;
const client = github.getOctokit(token, {userAgent: USER_AGENT});
const client = github.getOctokit(token, { userAgent: USER_AGENT });
for (const vulnerability of vulnerabilities) {
const reported = await alreadyReported(
@@ -278,6 +279,7 @@ export async function reportIssues(
repo: repo,
title: `${vulnerability.advisory.id}: ${vulnerability.advisory.title}`,
body: body,
labels,
});
core.info(
`Created an issue for ${vulnerability.advisory.id}: ${issue.data.html_url}`,