Skip to content

Commit

Permalink
Repo Gardening: ping in slack for issues labeled customer report (#41027
Browse files Browse the repository at this point in the history
)

* Repo Gardening: ping in slack for issues labeled customer report

Internal references:

- p1736823216576659-slack-C01UW7SB411
- pfVjQF-su-p2

* Update wording

---------

Co-authored-by: Ikem <66711744+inaikem@users.noreply.github.com>
  • Loading branch information
jeherve and inaikem authored Jan 14, 2025
1 parent f7897e3 commit af9a01e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Support References: send Slack message when an issue is labeled as customer report.
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>}
*/
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 );
Expand All @@ -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 );
}

/**
Expand Down Expand Up @@ -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 );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit af9a01e

Please sign in to comment.