Skip to content

Commit c06fe21

Browse files
committed
Check issue cleaned
1 parent 066bc40 commit c06fe21

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/action.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ const updateIssues = async (octokit, context, componentsToIssues, componentsToUp
284284
}
285285
}
286286

287-
const postDriftDetectionSummary = async (context, maxOpenedIssues, componentsToIssues, componentsToNewlyCreatedIssues, componentsCandidatesToCreateIssue, removedComponents, recoveredComponents, driftingComponents) => {
287+
const postDriftDetectionSummary = async (context, maxOpenedIssues, componentsToIssues, componentsToNewlyCreatedIssues, componentsCandidatesToCreateIssue, removedComponents, recoveredComponents, driftingComponents, erroredComponents) => {
288288
const orgName = context.repo.owner;
289289
const repo = context.repo.repo;
290290
const runId = github.context.runId;
@@ -295,14 +295,22 @@ const postDriftDetectionSummary = async (context, maxOpenedIssues, componentsToI
295295
for (let slug of Object.keys(componentsToNewlyCreatedIssues)) {
296296
const issueNumber = componentsToNewlyCreatedIssues[slug];
297297

298-
table.push( `| [${slug}](https://github.com/${orgName}/${repo}/actions/runs/${runId}#user-content-result-${slug}) | ![drifted](https://shields.io/badge/DRIFTED-important?style=for-the-badge "drifted") | New drift detected. Created new issue [#${issueNumber}](https://github.com/${orgName}/${repo}/issues/${issueNumber}) |`);
298+
if (driftingComponents.hasOwnProperty(slug)) {
299+
table.push( `| [${slug}](https://github.com/${orgName}/${repo}/actions/runs/${runId}#user-content-result-${slug}) | ![drifted](https://shields.io/badge/DRIFTED-important?style=for-the-badge "Drifted") | New drift detected. Created new issue [#${issueNumber}](https://github.com/${orgName}/${repo}/issues/${issueNumber}) |`);
300+
} else if (erroredComponents.hasOwnProperty(slug)) {
301+
table.push( `| [${slug}](https://github.com/${orgName}/${repo}/actions/runs/${runId}#user-content-result-${slug}) | ![failed](https://shields.io/badge/FAILED-ff0000?style=for-the-badge "Failed") | Failure detected. Created new issue [#${issueNumber}](https://github.com/${orgName}/${repo}/issues/${issueNumber}) |`);
302+
}
299303
}
300304

301305
for (let i = 0; i < componentsCandidatesToCreateIssue.length; i++) {
302306
const slug = componentsCandidatesToCreateIssue[i];
303307

304308
if (!componentsToNewlyCreatedIssues.hasOwnProperty(slug)) {
305-
table.push( `| [${slug}](https://github.com/${orgName}/${repo}/actions/runs/${runId}#user-content-result-${slug}) | ![drifted](https://shields.io/badge/DRIFTED-important?style=for-the-badge "drifted") | New drift detected. Issue was not created because maximum number of created issues ${maxOpenedIssues} reached |`);
309+
if (driftingComponents.hasOwnProperty(slug)) {
310+
table.push( `| [${slug}](https://github.com/${orgName}/${repo}/actions/runs/${runId}#user-content-result-${slug}) | ![drifted](https://shields.io/badge/DRIFTED-important?style=for-the-badge "Drifted") | New drift detected. Issue was not created because maximum number of created issues ${maxOpenedIssues} reached |`);
311+
} else if (erroredComponents.hasOwnProperty(slug)) {
312+
table.push( `| [${slug}](https://github.com/${orgName}/${repo}/actions/runs/${runId}#user-content-result-${slug}) | ![failed](https://shields.io/badge/FAILED-ff0000?style=for-the-badge "Failed") | Failure detected. Issue was not created because maximum number of created issues ${maxOpenedIssues} reached |`);
313+
}
306314
}
307315
}
308316

@@ -329,6 +337,15 @@ const postDriftDetectionSummary = async (context, maxOpenedIssues, componentsToI
329337
}
330338
}
331339

340+
for (let i = 0; i < erroredComponents.length; i++) {
341+
const slug = erroredComponents[i];
342+
const issueNumber = componentsToIssues[slug];
343+
344+
if (componentsCandidatesToCreateIssue.indexOf(slug) === -1) {
345+
table.push( `| [${slug}](https://github.com/${orgName}/${repo}/actions/runs/${runId}#user-content-result-${slug}) | ![failed](https://shields.io/badge/FAILED-ff0000?style=for-the-badge "Failed") | Failure detected. Issue already exists [#${issueNumber}](https://github.com/${orgName}/${repo}/issues/${issueNumber}) |`);
346+
}
347+
}
348+
332349
if (table.length > 1) {
333350
await core.summary
334351
.addRaw('# Drift Detection Summary', true)
@@ -391,7 +408,7 @@ const runAction = async (octokit, context, parameters) => {
391408

392409
await updateIssues(octokit, context, componentsToIssueNumber, componentsToUpdateExistingIssue);
393410

394-
await postDriftDetectionSummary(context, maxOpenedIssues, componentsToIssueNumber, componentsToNewlyCreatedIssues, componentsCandidatesToCreateIssue, removedComponents, recoveredComponents, driftingComponents);
411+
await postDriftDetectionSummary(context, maxOpenedIssues, componentsToIssueNumber, componentsToNewlyCreatedIssues, componentsCandidatesToCreateIssue, removedComponents, recoveredComponents, driftingComponents, erroredComponents);
395412

396413
await postStepSummaries(driftingComponents, erroredComponents);
397414
};

0 commit comments

Comments
 (0)