diff --git a/projects/github-actions/repo-gardening/changelog/add-repo-gardening-slack-message-customer-reports b/projects/github-actions/repo-gardening/changelog/add-repo-gardening-slack-message-customer-reports new file mode 100644 index 0000000000000..03ad960a6fa7e --- /dev/null +++ b/projects/github-actions/repo-gardening/changelog/add-repo-gardening-slack-message-customer-reports @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Support References: send Slack message when an issue is labeled as customer report. diff --git a/projects/github-actions/repo-gardening/src/tasks/gather-support-references/index.js b/projects/github-actions/repo-gardening/src/tasks/gather-support-references/index.js index 1fe15ebc63b42..17b31aefa24fd 100644 --- a/projects/github-actions/repo-gardening/src/tasks/gather-support-references/index.js +++ b/projects/github-actions/repo-gardening/src/tasks/gather-support-references/index.js @@ -412,13 +412,19 @@ async function createOrUpdateComment( payload, octokit, issueReferences, issueCo /** * Add a label to the issue, if it does not exist yet. * - * @param {GitHub} octokit - Initialized Octokit REST client. - * @param {string} ownerLogin - Repository owner login. - * @param {string} repo - Repository name. - * @param {number} number - Issue number. + * @param {WebhookPayloadIssue} payload - Issue or issue comment event payload. + * @param {GitHub} octokit - Initialized Octokit REST client. * @return {Promise} */ -async function addHappinessLabel( octokit, ownerLogin, repo, number ) { +async function addHappinessLabel( payload, octokit ) { + const { + issue: { number }, + repository: { + name: repo, + owner: { login: ownerLogin }, + }, + } = payload; + const happinessLabel = 'Customer Report'; const labels = await getLabels( octokit, ownerLogin, repo, number ); @@ -436,6 +442,18 @@ async function addHappinessLabel( octokit, ownerLogin, repo, number ) { issue_number: number, labels: [ happinessLabel ], } ); + + // Send Slack notification, if we have the necessary tokens. + // No Slack tokens, we won't be able to escalate. Bail. + const slackToken = getInput( 'slack_token' ); + const channel = getInput( 'slack_quality_channel' ); + if ( ! slackToken || ! channel ) { + return false; + } + + const message = `This issue has been labeled as a Customer Report. Please complete first-line triage within 24 hours.`; + const slackMessageFormat = formatSlackMessage( payload, channel, message ); + await sendSlackMessage( message, channel, payload, slackMessageFormat ); } /** @@ -464,7 +482,7 @@ async function gatherSupportReferences( payload, octokit ) { if ( issueReferences.length > 0 ) { debug( `gather-support-references: Found ${ issueReferences.length } references.` ); await createOrUpdateComment( payload, octokit, issueReferences, issueComments ); - await addHappinessLabel( octokit, owner.login, repo, number ); + await addHappinessLabel( payload, octokit ); } } diff --git a/projects/github-actions/repo-gardening/src/tasks/gather-support-references/readme.md b/projects/github-actions/repo-gardening/src/tasks/gather-support-references/readme.md index 16fc1e76945b8..c5878c415d398 100644 --- a/projects/github-actions/repo-gardening/src/tasks/gather-support-references/readme.md +++ b/projects/github-actions/repo-gardening/src/tasks/gather-support-references/readme.md @@ -2,7 +2,7 @@ Happiness Engineers can comment on issues to add references to support interactions with customers that would like to be updated whenever the problem is solved. -This task creates a new comment that lists all support references found in all comments on the issue. If it finds a support reference, it will also add a label to the issue, "Customer Report". +This task creates a new comment that lists all support references found in all comments on the issue. If it finds a support reference, it will also add a label to the issue, "Customer Report". When that label is added, we warn the triage team in Slack. The tasks also monitors the number of support references it has gathered: