Skip to content

Commit 2b935b4

Browse files
authored
Merge pull request atom#21430 from atom/merge-dependency-bumps
Merge dependency bumps
2 parents 755533b + ab5e729 commit 2b935b4

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

script/lib/update-dependency/main.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ const path = require('path');
55
const { repositoryRootPath } = require('../../config');
66
const packageJSON = require(path.join(repositoryRootPath, 'package.json'));
77
const git = simpleGit(repositoryRootPath);
8-
const { createPR, findPR, addLabel } = require('./pull-request');
8+
const {
9+
createPR,
10+
findPR,
11+
addLabel,
12+
findOpenPRs,
13+
checkCIstatus,
14+
mergePR
15+
} = require('./pull-request');
916
const runApmInstall = require('../run-apm-install');
1017
const {
1118
makeBranch,
@@ -94,4 +101,22 @@ module.exports = async function() {
94101
} catch (ex) {
95102
console.log(ex.message);
96103
}
104+
105+
// merge previous bumps that passed CI requirements
106+
try {
107+
const {
108+
data: { items }
109+
} = await findOpenPRs();
110+
for (const { title } of items) {
111+
const ref = title.replace('⬆️ ', '').replace('@', '-');
112+
const {
113+
data: { state }
114+
} = await checkCIstatus({ ref });
115+
if (state === 'success') {
116+
await mergePR({ ref });
117+
}
118+
}
119+
} catch (ex) {
120+
console.log(ex);
121+
}
97122
};

script/lib/update-dependency/pull-request.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ module.exports = {
3131
q: `${moduleName} type:pr ${moduleName}@${latest} in:title repo:atom/atom head:${branch}`
3232
});
3333
},
34+
findOpenPRs: async () => {
35+
return requestWithAuth('GET /search/issues', {
36+
q: 'type:pr repo:atom/atom state:open label:"depency ⬆️"'
37+
});
38+
},
39+
checkCIstatus: async ({ ref }) => {
40+
return requestWithAuth('GET /repos/:owner/:repo/commits/:ref/status', {
41+
ref
42+
});
43+
},
44+
mergePR: async ({ ref }) => {
45+
return requestWithAuth('POST /repos/{owner}/{repo}/merges', {
46+
base: 'master',
47+
head: ref
48+
});
49+
},
3450
addLabel: async pullRequestNumber => {
3551
return requestWithAuth('PATCH /repos/:owner/:repo/issues/:issue_number', {
3652
labels: ['depency ⬆️'],

0 commit comments

Comments
 (0)