mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Update children script (#6650)
* Update children script version 2 * save exact
This commit is contained in:
55
scripts/travis/update/pr-creator.js
Normal file
55
scripts/travis/update/pr-creator.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const GitHub = require('github-api');
|
||||
let program = require('commander');
|
||||
|
||||
const ORGANISATION = 'Alfresco';
|
||||
|
||||
class PrCreator {
|
||||
constructor(githubUser, githubRepo, token) {
|
||||
this.github = new GitHub({token});
|
||||
this.repo = this.github.getRepo(githubUser, githubRepo);
|
||||
}
|
||||
|
||||
async create(title, head, base) {
|
||||
const { data: prs } = await this.repo.listPullRequests({ state: 'open', head: `${ORGANISATION}:${head}`, base });
|
||||
|
||||
if (prs.length < 1) {
|
||||
const { data: pr } = await this.repo.createPullRequest({ title, head, base });
|
||||
return pr.number;
|
||||
}
|
||||
|
||||
return prs[0].number;
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('--host [type]', 'Remote environment host adf.lab.com ')
|
||||
.option('-t, --token [type]', 'token')
|
||||
.option('-h, --head [type]', 'head')
|
||||
.option('-r, --repo [type]', 'repo')
|
||||
.option('-title, --title [type]', 'title')
|
||||
.parse(process.argv);
|
||||
|
||||
console.log('process.argv ', program);
|
||||
|
||||
const { token, title, head, repo } = program,
|
||||
prCreator = new PrCreator(ORGANISATION, repo, token);
|
||||
|
||||
if (!token || !head || !title) {
|
||||
throw new Error('Each of the parameters have to be provided. --token, --title, --head');
|
||||
}
|
||||
|
||||
return prCreator.create(title, head, 'develop');
|
||||
}
|
||||
|
||||
main()
|
||||
.then(prNumber => {
|
||||
console.log(prNumber)
|
||||
process.exit(0);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
Reference in New Issue
Block a user