From 5151466bab761cd6124d630a8a77d10b1cecbdc9 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 27 May 2021 09:49:44 -0400 Subject: [PATCH] Updated DevTools bug Workflow Workflow now auto-assigns issues needing more information to the person who reported them --- .github/workflows/devtools_check_repro.yml | 52 ++++++++++------------ 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/workflows/devtools_check_repro.yml b/.github/workflows/devtools_check_repro.yml index 0d569a87fd912..e0335e905939e 100644 --- a/.github/workflows/devtools_check_repro.yml +++ b/.github/workflows/devtools_check_repro.yml @@ -45,12 +45,20 @@ jobs: debug(`found URL "${url}"`); debug(`found repro steps "${reproSteps}"`); - function formatComment(comment) { - return comment + async function createComment(comment) { + // Format + comment = comment .split("\n") .map((line) => line.trim()) .join("\n") .trim(); + + await github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment, + }); } async function getGitHubActionComments() { @@ -78,6 +86,16 @@ jobs: return issues.data; } + async function updateIssue(state, assignees = []) { + await github.issues.update({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + state, + assignees, + }); + } + async function closeWithComment(comment) { if (issue.state !== 'open') { debug(`Issue is not open`); @@ -106,19 +124,8 @@ jobs: labels: [LABEL_NEEDS_MORE_INFORMATION], }); - await github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: formatComment(comment), - }); - - await github.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - state: 'closed', - }); + await createComment(comment); + await updateIssue('closed', [user]); } async function openWithComment(comment) { @@ -149,19 +156,8 @@ jobs: name: LABEL_NEEDS_MORE_INFORMATION, }); - await github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: formatComment(comment), - }); - - await github.issues.update({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - state: 'open', - }); + await createComment(comment); + await updateIssue('open'); } const PROBABLY_NOT_A_URL_REGEX = /(^Chrome$|^Firefox$| Website)/i;