aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/utils/discord.ts
blob: 2482a18f07ddf64ab6ba59b6d7231d05a712f7e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { fetchAsync } from '@0x/utils';

import { constants } from '../constants';

import { utils } from './utils';

export const alertDiscord = async (releaseNotes: string): Promise<boolean> => {
    const webhookUrl = constants.discordAlertWebhookUrl;
    if (!webhookUrl) {
        utils.log('Not alerting to discord because webhook url not set');
        return false;
    }

    utils.log('Alerting discord...');
    const payload = {
        content: `New monorepo package released!  View at https://github.com/0xProject/0x-monorepo/releases \n\n ${releaseNotes}`,
    };
    await fetchAsync(webhookUrl, {
        method: 'POST',
        headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(payload),
    });
    return true;
};