Skip to content

Commit a5e7d8c

Browse files
authored
Slack team ref (#46)
* fix slack handle lookup
1 parent 5570254 commit a5e7d8c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

.github/scripts/slack-release-testing.mjs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function initializeSlackTeams() {
5454

5555
if (response.ok && response.usergroups) {
5656
slackTeamsMap = response.usergroups.reduce((map, group) => {
57-
map[group.name] = group.id;
57+
map[group.handle] = group.id;
5858
return map;
5959
}, {});
6060
} else {
@@ -319,20 +319,31 @@ async function getPublishChannelName(release) {
319319
}
320320

321321
async function fmtSlackHandle(team) {
322-
//Notify if they have pending validations or have not completed signoff
322+
// Notify if they have pending validations or have not completed signoff
323323
const shouldNotify =
324324
team.pendingValidations > 0 ||
325325
team.status.trim().toLowerCase() !== 'completed';
326-
//Don't notify teams when in testOnly mode
326+
327+
// Don't notify teams when in testOnly mode
327328
if (testOnly()) {
328329
return shouldNotify ? ` - @${team.slackHandle}` : '';
329330
}
330331

331-
//Lookup Slack Team Id for real notifications
332-
const slackTeamId = slackTeamsMap[teamName];
333-
return shouldNotify ? ` - <!subteam^${slackTeamId}>` : '';
332+
// Lookup Slack Team Id for real notifications
333+
const slackTeamId = slackTeamsMap[`${team.slackHandle}`];
334+
335+
// Check if slackTeamId is not found in the map
336+
if (!slackTeamId) {
337+
console.log(
338+
`Slack team ID not found for handle: ${team.slackHandle}`,
339+
);
340+
return '';
341+
}
342+
343+
return shouldNotify ? ` - <!subteam^${slackTeamId}|team>` : '';
334344
}
335345

346+
336347
/**
337348
* Publishes the testing status for a release to the appropriate Slack channel
338349
* @param {Object} release represents a release

0 commit comments

Comments
 (0)