Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .github/scripts/slack-release-testing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function initializeSlackTeams() {

if (response.ok && response.usergroups) {
slackTeamsMap = response.usergroups.reduce((map, group) => {
map[group.name] = group.id;
map[group.handle] = group.id;
return map;
}, {});
} else {
Expand Down Expand Up @@ -319,20 +319,31 @@ async function getPublishChannelName(release) {
}

async function fmtSlackHandle(team) {
//Notify if they have pending validations or have not completed signoff
// Notify if they have pending validations or have not completed signoff
const shouldNotify =
team.pendingValidations > 0 ||
team.status.trim().toLowerCase() !== 'completed';
//Don't notify teams when in testOnly mode

// Don't notify teams when in testOnly mode
if (testOnly()) {
return shouldNotify ? ` - @${team.slackHandle}` : '';
}

//Lookup Slack Team Id for real notifications
const slackTeamId = slackTeamsMap[teamName];
return shouldNotify ? ` - <!subteam^${slackTeamId}>` : '';
// Lookup Slack Team Id for real notifications
const slackTeamId = slackTeamsMap[`${team.slackHandle}`];

// Check if slackTeamId is not found in the map
if (!slackTeamId) {
console.log(
`Slack team ID not found for handle: ${team.slackHandle}`,
);
return '';
}

return shouldNotify ? ` - <!subteam^${slackTeamId}|team>` : '';
}


/**
* Publishes the testing status for a release to the appropriate Slack channel
* @param {Object} release represents a release
Expand Down