@@ -15,11 +15,26 @@ export async function runPushAlert(args) {
15
15
const commit = process . env . GITHUB_SHA ;
16
16
const reviewed = await verifyCommitReview ( client , commit ) ;
17
17
if ( reviewed === false ) {
18
+ const commitDetails = await client . git . getCommit ( {
19
+ repo : github . context . repo . repo ,
20
+ owner : github . context . repo . owner ,
21
+ commit_sha : commit ,
22
+ } ) ;
23
+
18
24
//notify channel
19
25
var github_commit_url = `https://github.com/${ github . context . repo . owner } /${ github . context . repo . repo } /commit/${ commit } ` ;
26
+ const message = `:red-c: @channel Unreviewed Commit in \`${ github . context . repo . owner } /${ github . context . repo . repo } \`\n` +
27
+ '\n' +
28
+ `*Commit:* <${ github_commit_url } |${ commit . slice ( 0 , 6 ) } >\n` +
29
+ `*Author:* <https://github.com/${ encodeURIComponent ( commitDetails . data . author . name ) } |${ safeSlackString ( commitDetails . data . author . name ) } >\n` +
30
+ `*Committer:* <https://github.com/${ encodeURIComponent ( commitDetails . data . committer . name ) } |${ safeSlackString ( commitDetails . data . committer . name ) } >\n` +
31
+ '*Message:*\n' +
32
+ '```\n'
33
+ safeSlackString ( commitDetails . data . message ) +
34
+ '\n```' ;
20
35
const req = request . post ( args . slackEndpoint , {
21
36
json :{
22
- text :`Unreviewed Commit from ${ github_commit_url } ` ,
37
+ text : message ,
23
38
channel : `#${ args . alertChannel } `
24
39
}
25
40
} , ( error , res , body ) => {
@@ -42,6 +57,10 @@ export async function runPushAlert(args) {
42
57
}
43
58
}
44
59
60
+ function safeSlackString ( s : string ) : string {
61
+ return s . replace ( / \& / g, '&' ) . replace ( / \< / g, '<' ) . replace ( / \> / g, '>' ) ;
62
+ }
63
+
45
64
async function verifyCommitReview (
46
65
client : InstanceType < typeof GitHub > ,
47
66
commit_sha : string
0 commit comments