@@ -12,14 +12,22 @@ module.exports = async ({ core, context, github }) => {
12
12
const repo = context . repo . repo ;
13
13
const issueNumber = context . issue . number ;
14
14
15
+ core . debug ( `>>> Context: ${ JSON . stringify ( context ) } ` ) ;
16
+
15
17
const issue = await github . rest . issues . get ( {
16
18
owner,
17
19
repo,
18
20
issue_number : issueNumber ,
19
21
} ) ;
20
22
21
- const issueAuthor = issue . data . user . login ;
22
- const commentAuthor = context . payload . comment . user . login ;
23
+ core . debug ( `>>> Issue data: ${ JSON . stringify ( issue . data ) } ` ) ;
24
+
25
+ const issueAuthor = issue . data . user ?. login ;
26
+ core . info ( `>>> Issue author: ${ issueAuthor } ` ) ;
27
+
28
+ // there is no comment when the issue gets closed, so we just assign null and continue with the action
29
+ const commentAuthor = context . payload . comment ?. user . login ;
30
+ core . info ( `>>> Comment author: ${ commentAuthor } ` ) ;
23
31
24
32
// return early if the author of the comment is not the same as the author of the issue
25
33
if ( issueAuthor !== commentAuthor ) {
@@ -28,6 +36,7 @@ module.exports = async ({ core, context, github }) => {
28
36
}
29
37
30
38
const labels = issue . data . labels . map ( ( label ) => label . name ) ;
39
+ core . debug ( `>>> Issue labels: ${ JSON . stringify ( labels ) } ` ) ;
31
40
32
41
const maintainerLabel = 'status: waiting for maintainer' ;
33
42
const authorLabel = 'status: waiting for author' ;
@@ -48,9 +57,13 @@ module.exports = async ({ core, context, github }) => {
48
57
const purgedLabels = labels . filter (
49
58
( label ) => label !== maintainerLabel && label !== authorLabel ,
50
59
) ;
60
+ core . info ( `>>> Purged labels: ${ JSON . stringify ( purgedLabels ) } ` ) ;
61
+
51
62
// check if the issue is closed or gets closed with this event
52
63
const issueIsOrGetsClosed =
53
64
context . payload . action === 'closed' || issue . data . state === 'closed' ;
65
+ core . info ( `>>> Issue is or gets closed: ${ issueIsOrGetsClosed } ` ) ;
66
+
54
67
// add maintainerLabel when issue is not/won't be closed
55
68
const labelsForUpdate = issueIsOrGetsClosed ? purgedLabels : [ ...purgedLabels , maintainerLabel ] ;
56
69
0 commit comments