@@ -32,22 +32,43 @@ async function fetchPatch(): Promise<string> {
32
32
}
33
33
34
34
const ctx = github . context
35
- if ( ctx . eventName !== `pull_request` ) {
35
+ if ( ctx . eventName !== `pull_request` && ctx . eventName !== `merge_group` ) {
36
36
core . info ( `Not fetching patch for showing only new issues because it's not a pull request context: event name is ${ ctx . eventName } ` )
37
37
return ``
38
38
}
39
- const pull = ctx . payload . pull_request
40
- if ( ! pull ) {
41
- core . warning ( `No pull request in context` )
39
+
40
+ let pullNumber : number | undefined ;
41
+
42
+ if ( ctx . eventName === `merge_group` ) {
43
+ const result = ctx . payload . merge_group . head_ref . match ( / p r - ( \d + ) - / ) ;
44
+ if ( result === null ) {
45
+ core . warning ( `No pull request number in merge_group context` )
46
+ return ``
47
+ }
48
+ pullNumber = parseInt ( result [ 1 ] , 10 )
49
+ }
50
+
51
+
52
+ if ( ctx . eventName === `pull_request` ) {
53
+ if ( ! ctx . payload . pull_request ) {
54
+ core . warning ( `No pull request in context` )
55
+ return ``
56
+ }
57
+ pullNumber = ctx . payload . pull_request . number
58
+ }
59
+
60
+ if ( pullNumber === undefined ) {
61
+ core . warning ( `No pull request number in context` )
42
62
return ``
43
63
}
64
+
44
65
const octokit = github . getOctokit ( core . getInput ( `github-token` , { required : true } ) )
45
66
let patch : string
46
67
try {
47
68
const patchResp = await octokit . rest . pulls . get ( {
48
69
owner : ctx . repo . owner ,
49
70
repo : ctx . repo . repo ,
50
- [ `pull_number` ] : pull . number ,
71
+ [ `pull_number` ] : pullNumber ,
51
72
mediaType : {
52
73
format : `diff` ,
53
74
} ,
0 commit comments