@@ -4,9 +4,19 @@ import Handlebars from "handlebars";
44import fs from "fs/promises" ;
55import { colorize } from "./helpers/colorize.js" ;
66import { getReleaseInfo } from "./contributors.js" ;
7+ import path from "path" ;
8+ import { fileURLToPath } from "url" ;
9+
10+ const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
11+
12+ const NOTIFY_PR_TEMPLATE = path . resolve ( __dirname , '../templates/pr_published.hbs' ) ;
713
814const normalizeTag = ( tag ) => tag ? 'v' + tag . replace ( / ^ v / , '' ) : '' ;
915
16+ const GITHUB_BOT_LOGIN = 'github-actions[bot]' ;
17+
18+ const skipCollaboratorPRs = true ;
19+
1020class RepoBot {
1121 constructor ( options ) {
1222 const {
@@ -15,7 +25,7 @@ class RepoBot {
1525 } = options || { } ;
1626
1727 this . templates = Object . assign ( {
18- published : '../templates/pr_published.hbs'
28+ published : NOTIFY_PR_TEMPLATE
1929 } , templates ) ;
2030
2131 this . github = api || new GithubAPI ( owner , repo ) ;
@@ -53,7 +63,18 @@ class RepoBot {
5363
5464 await this . github . appendLabels ( id , [ tag ] ) ;
5565
56- if ( isBot || labels . find ( ( { name} ) => name === 'automated pr' ) || ( await this . github . isCollaborator ( login ) ) ) {
66+ if ( isBot || labels . find ( ( { name} ) => name === 'automated pr' ) || ( skipCollaboratorPRs && await this . github . isCollaborator ( login ) ) ) {
67+ return false ;
68+ }
69+
70+ const comments = await this . github . getComments ( id , { desc : true } ) ;
71+
72+ const comment = comments . find (
73+ ( { body, user} ) => user . login === GITHUB_BOT_LOGIN && body . indexOf ( 'published in' ) >= 0
74+ )
75+
76+ if ( comment ) {
77+ console . log ( colorize ( ) `Release comment [${ comment . html_url } ] already exists in #${ pr . id } ` ) ;
5778 return false ;
5879 }
5980
0 commit comments