merge dependency bumps

This commit is contained in:
darangi
2020-10-02 12:06:03 +01:00
parent 0f2975930e
commit ab5e729e31
2 changed files with 42 additions and 1 deletions

View File

@@ -5,7 +5,14 @@ const path = require('path');
const { repositoryRootPath } = require('../../config');
const packageJSON = require(path.join(repositoryRootPath, 'package.json'));
const git = simpleGit(repositoryRootPath);
const { createPR, findPR, addLabel } = require('./pull-request');
const {
createPR,
findPR,
addLabel,
findOpenPRs,
checkCIstatus,
mergePR
} = require('./pull-request');
const runApmInstall = require('../run-apm-install');
const {
makeBranch,
@@ -94,4 +101,22 @@ module.exports = async function() {
} catch (ex) {
console.log(ex.message);
}
// merge previous bumps that passed CI requirements
try {
const {
data: { items }
} = await findOpenPRs();
for (const { title } of items) {
const ref = title.replace('⬆️ ', '').replace('@', '-');
const {
data: { state }
} = await checkCIstatus({ ref });
if (state === 'success') {
await mergePR({ ref });
}
}
} catch (ex) {
console.log(ex);
}
};

View File

@@ -31,6 +31,22 @@ module.exports = {
q: `${moduleName} type:pr ${moduleName}@${latest} in:title repo:atom/atom head:${branch}`
});
},
findOpenPRs: async () => {
return requestWithAuth('GET /search/issues', {
q: 'type:pr repo:atom/atom state:open label:"depency ⬆️"'
});
},
checkCIstatus: async ({ ref }) => {
return requestWithAuth('GET /repos/:owner/:repo/commits/:ref/status', {
ref
});
},
mergePR: async ({ ref }) => {
return requestWithAuth('POST /repos/{owner}/{repo}/merges', {
base: 'master',
head: ref
});
},
addLabel: async pullRequestNumber => {
return requestWithAuth('PATCH /repos/:owner/:repo/issues/:issue_number', {
labels: ['depency ⬆️'],