Skip to content

Commit

Permalink
Merge pull request #305 from cloudposse/fix/action/safer-description-…
Browse files Browse the repository at this point in the history
…handling

fix: summary file crashes
  • Loading branch information
dudymas authored Dec 29, 2023
2 parents 9f21bc2 + 597d23d commit 6f8486b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ const createIssues = async (octokit, context, maxOpenedIssues, labels, users, co
for (let i = 0; i < numOfIssuesToCreate; i++) {
const slug = componentsCandidatesToCreateIssue[i];
const issueTitle = erroredComponents.includes(slug) ? `Failure Detected in \`${slug}\`` : `Drift Detected in \`${slug}\``;
const file_name = slug.replace("/", "_")
const file_name = slug.replace(/\//g, "_")
if (!fs.existsSync(`issue-description-${file_name}.md`)) {
core.error(`Failed to create issue for component ${slug} because file "issue-description-${file_name}.md" does not exist`);
continue;
}
const issueDescription = fs.readFileSync(`issue-description-${file_name}.md`, 'utf8');

const label = erroredComponents.includes(slug) ? "error" : "drift"
Expand Down Expand Up @@ -299,7 +303,7 @@ const updateIssues = async (octokit, context, componentsToIssues, componentsToUp

for (let i = 0; i < componentsToUpdateExistingIssue.length; i++) {
const slug = componentsToUpdateExistingIssue[i];
const file_name = slug.replace("/", "_")
const file_name = slug.replace(/\//g, "_")
const issueDescription = fs.readFileSync(`issue-description-${file_name}.md`, 'utf8');
const issueNumber = componentsToIssues[slug].number;

Expand Down Expand Up @@ -390,7 +394,7 @@ const postStepSummaries = async (driftingComponents, erroredComponents) => {
const components = driftingComponents.concat(erroredComponents)
for (let i = 0; i < components.length; i++) {
const slug = components[i];
const file_name = slug.replace("/", "_")
const file_name = slug.replace(/\//g, "_")
const file = `step-summary-${file_name}.md`;
const content = fs.readFileSync(file, 'utf-8');

Expand Down

0 comments on commit 6f8486b

Please sign in to comment.