Skip to content

Commit

Permalink
add pause before trying to comment
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorFries committed Nov 6, 2024
1 parent 157135b commit 0d52078
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ export const createAndCloseExistingIssue = async (issueTitle, issueBody, issueCo
// Create new Issue.
await createIssue(issueTitle, decodeURIComponent(issueBody));

setTimeout(() => {
console.log("pausing for issue to be created...", 2000);
});

const newIssueNumber = await findIssueByTitle(issueTitle);

// Add comment to Issue.
await addComment(issueTitle, issueComment);
await addComment(newIssueNumber, issueComment);
};

export default createAndCloseExistingIssue;
16 changes: 3 additions & 13 deletions .github/helpers/github-api/github-api-requests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,13 @@ export async function closeIssue(issue_number) {

/**
* Get issue number from title, and create a request to add a comment.
* @param {*} issueTitle - the title of the comment to comment on
* @param {*} issueNumber - the number for the issue to comment on
* @param {*} issueComment - the comment to add
* @returns - requestData - Data returned by the request.
* @example
* addComment('My Issue', 'An example comment');
* addComment(1234, 'An example comment');
*/
export async function addComment(issueTitle, issueComment) {
let issueNumber = await findIssueByTitle(issueTitle);
let counter = 1;

while ( typeof issueNumber !== 'number' && counter < 5){
setTimeout(() =>
console.log(`no issue with ${issueTitle} found, pausing...`), counter * 1000);
issueNumber = await findIssueByTitle(issueTitle);
counter++;
};

export async function addComment(issueNumber, issueComment) {
const request = await octokit.rest.issues.createComment({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
Expand Down

0 comments on commit 0d52078

Please sign in to comment.