7
7
const fetch = require ( 'node-fetch' ) ;
8
8
const parseTitle = require ( 'probot-app-label-release-pr/parse-title.js' ) ;
9
9
10
+ const ORG_WHITELIST = ( whitelist =>
11
+ whitelist ? whitelist . split ( ',' ) : [ ]
12
+ ) ( process . env . RELEASE_VERIFICATION_ORG_WHITELIST ) ;
13
+
10
14
module . exports = robot => {
11
15
robot . on ( 'pull_request.opened' , nonReleaseStatus ) ;
12
16
robot . on ( 'pull_request.reopened' , nonReleaseStatus ) ;
@@ -20,6 +24,10 @@ module.exports = robot => {
20
24
* We auto-pass the status so we can block on this status across repos.
21
25
*/
22
26
async function nonReleaseStatus ( context ) {
27
+ if ( ! getIsWhitelisted ( context . payload ) ) {
28
+ return ;
29
+ }
30
+
23
31
const { github} = context ;
24
32
const pr = context . payload . pull_request ;
25
33
const isRelease = parseTitle ( pr . title ) ;
@@ -32,6 +40,10 @@ module.exports = robot => {
32
40
}
33
41
34
42
async function handleClosedPR ( context ) {
43
+ if ( ! getIsWhitelisted ( context . payload ) ) {
44
+ return ;
45
+ }
46
+
35
47
const { github} = context ;
36
48
const pr = context . payload . pull_request ;
37
49
@@ -65,6 +77,10 @@ module.exports = robot => {
65
77
}
66
78
67
79
async function checkReleaseLabel ( context ) {
80
+ if ( ! getIsWhitelisted ( context . payload ) ) {
81
+ return ;
82
+ }
83
+
68
84
const { github} = context ;
69
85
const pr = context . payload . pull_request ;
70
86
@@ -119,6 +135,10 @@ module.exports = robot => {
119
135
}
120
136
} ;
121
137
138
+ function getIsWhitelisted ( payload ) {
139
+ return ! ORG_WHITELIST . length || ORG_WHITELIST . includes ( payload . repository . owner . login ) ;
140
+ }
141
+
122
142
// PR titles should have a dash in it to be considered a prerelease.
123
143
// E.g., v1.0.0-alpha1
124
144
function getIsPrerelease ( prTitle ) {
0 commit comments