mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-11 12:12:55 +00:00
feat: make slack notification optional
This commit is contained in:
@@ -51,7 +51,9 @@ export async function remind(api: Api): Promise<void> {
|
|||||||
Logger.info(`Found ${mergeRequests.length} open merge requests.`);
|
Logger.info(`Found ${mergeRequests.length} open merge requests.`);
|
||||||
|
|
||||||
// instantiate slack client
|
// instantiate slack client
|
||||||
const client = new WebClient(process.env.SLACK_API_TOKEN);
|
const client = typeof process.env.SLACK_API_TOKEN !== 'undefined' ?
|
||||||
|
new WebClient(process.env.SLACK_API_TOKEN) :
|
||||||
|
undefined;
|
||||||
|
|
||||||
// get members of main group
|
// get members of main group
|
||||||
const members = await api.getMembers(MembershipScope.GROUPS, GROUPS[0]);
|
const members = await api.getMembers(MembershipScope.GROUPS, GROUPS[0]);
|
||||||
@@ -136,7 +138,7 @@ export async function remind(api: Api): Promise<void> {
|
|||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
||||||
// send message to slack
|
// send message to slack
|
||||||
await client.chat.postMessage({
|
await client?.chat.postMessage({
|
||||||
channel: SLACK_CHANNEL,
|
channel: SLACK_CHANNEL,
|
||||||
text: `Merge request '${mergeRequest.title}' needs more approvals! See ${mergeRequest.web_url}!`,
|
text: `Merge request '${mergeRequest.title}' needs more approvals! See ${mergeRequest.web_url}!`,
|
||||||
});
|
});
|
||||||
@@ -152,7 +154,7 @@ export async function remind(api: Api): Promise<void> {
|
|||||||
Logger.log(`Merge request '${mergeRequest.title}' is ready to be merged!`);
|
Logger.log(`Merge request '${mergeRequest.title}' is ready to be merged!`);
|
||||||
|
|
||||||
// send message to slack
|
// send message to slack
|
||||||
await client.chat.postMessage({
|
await client?.chat.postMessage({
|
||||||
channel: SLACK_CHANNEL,
|
channel: SLACK_CHANNEL,
|
||||||
text: `Merge request '${mergeRequest.title}' is ready to be merged! See ${mergeRequest.web_url}!`,
|
text: `Merge request '${mergeRequest.title}' is ready to be merged! See ${mergeRequest.web_url}!`,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user