/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v15.5.22
scripts/release/slack.ts
40 строк
1 KB
Jiwon Choi
[release] notify release status via slack (#79409)
23 май 2025, 18:04
Не верифицирован
23 май 2025, 18:04
56c3ae8
Код
Авторство
О чём код?
import { WebClient } from '@slack/web-api' async function slack() { if (!process.env.SLACK_TOKEN) { throw new Error('SLACK_TOKEN not set') } const workflowLink = process.env.WORKFLOW_LINK if (!workflowLink) { throw new Error('WORKFLOW_LINK not set') } const channel = process.env.SLACK_CHANNEL_ID ?? 'C0668R2391V' // #next-releases // TODO: Configure SLACK_ envs for dry run testing to not ping the oncall. // TODO: It'll become `@oncall-nextjs` const ping = process.env.SLACK_PING ?? '@nextjs-oncall' const message = process.env.SLACK_MESSAGE ?? process.env.RELEASE_STATUS === 'true' ? `Successfully published a new release!\n<https://github.com/vercel/next.js/releases|Releases Link>` : `Failed to publish a new release triggered by "${process.env.WORKFLOW_ACTOR}". ${ping}\n<${workflowLink}|Workflow Link>` const slackClient = new WebClient(process.env.SLACK_TOKEN) const res = await slackClient.chat.postMessage({ channel, text: message, username: 'Next.js Bot', icon_emoji: ':nextjs:', }) if (!res.ok) { throw new Error( `Failed to send message "${message}" to Slack channel #next-releases: ${res.error}` ) } console.log('Successfully sent message to Slack!') } slack()