bcgov/citz-imb-staff-purchasing-reimbursement

View on GitHub
.github/helpers/github-api/create-and-close-existing-issue.js

Summary

Maintainability
A
0 mins
Test Coverage
const { createIssue, closeIssue, findIssueByTitle } = require('./github-api-requests');
const { ISSUE_TITLE, ISSUE_BODY } = process.env;

(async () => {
  // Check for existing Issue.
  const existingIssueNumber = await findIssueByTitle(ISSUE_TITLE);

  if (existingIssueNumber && !Number.isNaN(Number(existingIssueNumber))) {
    // Close old Issue.
    await closeIssue(Number(existingIssueNumber));
  }

  // Create new Issue.
  await createIssue(ISSUE_TITLE, decodeURIComponent(ISSUE_BODY));
})();