mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 19:22:51 +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.`);
|
||||
|
||||
// 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
|
||||
const members = await api.getMembers(MembershipScope.GROUPS, GROUPS[0]);
|
||||
@@ -136,7 +138,7 @@ export async function remind(api: Api): Promise<void> {
|
||||
.join(', ');
|
||||
|
||||
// send message to slack
|
||||
await client.chat.postMessage({
|
||||
await client?.chat.postMessage({
|
||||
channel: SLACK_CHANNEL,
|
||||
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!`);
|
||||
|
||||
// send message to slack
|
||||
await client.chat.postMessage({
|
||||
await client?.chat.postMessage({
|
||||
channel: SLACK_CHANNEL,
|
||||
text: `Merge request '${mergeRequest.title}' is ready to be merged! See ${mergeRequest.web_url}!`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user