Skip to content

Commit 93e5bdf

Browse files
chrisdothtmlfusion-bot[bot]
authored and
fusion-bot[bot]
committed
Support release verification org whitelist
#138 Co-authored-by: Chris Deacy <deacy@uber.com>
1 parent 9ace2ec commit 93e5bdf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/release-verification.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
const fetch = require('node-fetch');
88
const parseTitle = require('probot-app-label-release-pr/parse-title.js');
99

10+
const ORG_WHITELIST = (whitelist =>
11+
whitelist ? whitelist.split(',') : []
12+
)(process.env.RELEASE_VERIFICATION_ORG_WHITELIST);
13+
1014
module.exports = robot => {
1115
robot.on('pull_request.opened', nonReleaseStatus);
1216
robot.on('pull_request.reopened', nonReleaseStatus);
@@ -20,6 +24,10 @@ module.exports = robot => {
2024
* We auto-pass the status so we can block on this status across repos.
2125
*/
2226
async function nonReleaseStatus(context) {
27+
if (!getIsWhitelisted(context.payload)) {
28+
return;
29+
}
30+
2331
const {github} = context;
2432
const pr = context.payload.pull_request;
2533
const isRelease = parseTitle(pr.title);
@@ -32,6 +40,10 @@ module.exports = robot => {
3240
}
3341

3442
async function handleClosedPR(context) {
43+
if (!getIsWhitelisted(context.payload)) {
44+
return;
45+
}
46+
3547
const {github} = context;
3648
const pr = context.payload.pull_request;
3749

@@ -65,6 +77,10 @@ module.exports = robot => {
6577
}
6678

6779
async function checkReleaseLabel(context) {
80+
if (!getIsWhitelisted(context.payload)) {
81+
return;
82+
}
83+
6884
const {github} = context;
6985
const pr = context.payload.pull_request;
7086

@@ -119,6 +135,10 @@ module.exports = robot => {
119135
}
120136
};
121137

138+
function getIsWhitelisted(payload) {
139+
return !ORG_WHITELIST.length || ORG_WHITELIST.includes(payload.repository.owner.login);
140+
}
141+
122142
// PR titles should have a dash in it to be considered a prerelease.
123143
// E.g., v1.0.0-alpha1
124144
function getIsPrerelease(prTitle) {

0 commit comments

Comments
 (0)