File tree Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -9,12 +9,23 @@ type TeamMember = { login: string };
9
9
10
10
if ( ! SLACK_BOT_TOKEN && NODE_ENV !== 'test' ) {
11
11
console . error ( 'Missing environment variable SLACK_BOT_TOKEN' ) ;
12
- process . exit ( 1 ) ;
13
12
}
14
13
15
14
const slack = new WebClient ( SLACK_BOT_TOKEN ) ;
16
15
17
- const octokit = new ProbotOctokit ( ) ;
16
+ let auth : any ;
17
+ if ( process . env . APP_ID && process . env . PRIVATE_KEY ) {
18
+ auth = {
19
+ appId : process . env . APP_ID ,
20
+ privateKey : process . env . PRIVATE_KEY ,
21
+ } ;
22
+ } else if ( process . env . GITHUB_TOKEN ) {
23
+ auth = { token : process . env . GITHUB_TOKEN } ;
24
+ } else {
25
+ console . warn ( 'Missing GitHub auth credentials, using unauthenticated requests.' ) ;
26
+ }
27
+
28
+ const octokit = new ProbotOctokit ( { auth } ) ;
18
29
19
30
function getOwnerAndRepoFromUrl ( url : string ) {
20
31
const urlObj = new URL ( url ) ;
@@ -211,18 +222,24 @@ async function main() {
211
222
}
212
223
213
224
if ( ! reminders . length ) {
225
+ console . info ( 'No PRs found needing reminders :)' ) ;
214
226
return ;
215
227
}
216
228
217
229
const text = `:blob-wave: *Reminder:* the following PRs are awaiting review.\n\n${ reminders . join (
218
230
'\n\n' ,
219
231
) } `;
220
232
221
- slack . chat . postMessage ( {
222
- channel : '#wg-api' ,
223
- unfurl_links : false ,
224
- text,
225
- } ) ;
233
+ if ( SLACK_BOT_TOKEN ) {
234
+ slack . chat . postMessage ( {
235
+ channel : '#wg-api' ,
236
+ unfurl_links : false ,
237
+ text,
238
+ } ) ;
239
+ } else {
240
+ // Log for testing without slack auth
241
+ console . log ( text ) ;
242
+ }
226
243
}
227
244
228
245
if ( require . main === module ) main ( ) ;
You can’t perform that action at this time.
0 commit comments