File tree 4 files changed +114
-1
lines changed
4 files changed +114
-1
lines changed Original file line number Diff line number Diff line change @@ -618,7 +618,15 @@ jobs:
618
618
if : steps.changesets.outputs.pullRequestNumber
619
619
run : ' gh pr edit ${{ steps.changesets.outputs.pullRequestNumber }} --add-label "created-by: CI"'
620
620
env :
621
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
621
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }
622
+
623
+ - name : Send a Slack notification of the publish status
624
+ run : pnpm tsx scripts/release/slack.ts
625
+ env :
626
+ SLACK_TOKEN : ${{ secrets.SLACK_TOKEN }}
627
+ RELEASE_STATUS : ${{ steps.changesets.outputs.published }}
628
+ WORKFLOW_LINK : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
629
+ WORKFLOW_ACTOR : ${{ github.actor }}
622
630
623
631
- name : Upload npm log artifact
624
632
if : steps.changesets.outputs.published == 'true'
Original file line number Diff line number Diff line change 118
118
"@picocss/pico" : " 1.5.10" ,
119
119
"@rspack/core" : " 1.3.9" ,
120
120
"@rspack/plugin-react-refresh" : " 1.2.0" ,
121
+ "@slack/web-api" : " 7.9.1" ,
121
122
"@swc/cli" : " 0.1.55" ,
122
123
"@swc/core" : " 1.11.24" ,
123
124
"@swc/helpers" : " 0.5.15" ,
Original file line number Diff line number Diff line change
1
+ import { WebClient } from '@slack/web-api'
2
+
3
+ async function slack ( ) {
4
+ if ( ! process . env . SLACK_TOKEN ) {
5
+ throw new Error ( 'SLACK_TOKEN not set' )
6
+ }
7
+
8
+ const workflowLink = process . env . WORKFLOW_LINK
9
+ if ( ! workflowLink ) {
10
+ throw new Error ( 'WORKFLOW_LINK not set' )
11
+ }
12
+
13
+ const channel = process . env . SLACK_CHANNEL_ID ?? 'C0668R2391V' // #next-releases
14
+ // TODO: Configure SLACK_ envs for dry run testing to not ping the oncall.
15
+ // TODO: It'll become `@oncall-nextjs`
16
+ const ping = process . env . SLACK_PING ?? '@nextjs-oncall'
17
+
18
+ const message =
19
+ process . env . SLACK_MESSAGE ?? process . env . RELEASE_STATUS === 'true'
20
+ ? `Successfully published a new release!\n<https://github.com/vercel/next.js/releases|Releases Link>`
21
+ : `Failed to publish a new release triggered by "${ process . env . WORKFLOW_ACTOR } ". ${ ping } \n<${ workflowLink } |Workflow Link>`
22
+
23
+ const slackClient = new WebClient ( process . env . SLACK_TOKEN )
24
+ const res = await slackClient . chat . postMessage ( {
25
+ channel,
26
+ text : message ,
27
+ username : 'Next.js Bot' ,
28
+ icon_emoji : ':nextjs:' ,
29
+ } )
30
+
31
+ if ( ! res . ok ) {
32
+ throw new Error (
33
+ `Failed to send message "${ message } " to Slack channel #next-releases: ${ res . error } `
34
+ )
35
+ }
36
+
37
+ console . log ( 'Successfully sent message to Slack!' )
38
+ }
39
+
40
+ slack ( )
You can’t perform that action at this time.
0 commit comments