-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (42 loc) · 1.44 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const gulp = require("gulp");
const axios = require("axios");
gulp.task("createpr", async () => {
// map input args to variables
const tokenInput = process.argv[4];
const sourceBranchInput = process.argv[6];
const bitbucketRepoOwnerInput = process.argv[8];
const bitbucketRepoSlugInput = process.argv[10];
const defaultReviewersInput = process.argv[12];
// create headers
const headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${tokenInput}`,
};
// parse default reviewers from string to object to array
const defaultReviewersParsed = JSON.parse(defaultReviewersInput);
const defaultReviewers = [];
defaultReviewersParsed.forEach(item => defaultReviewers.push(item));
// create json payload
const postData = {
title: 'Dependency arcimoto-aws-services release: update of submodule required',
description: 'The `arcimoto-aws-services` repo was updated and this dependent repository needs to bring in those upstream changes.',
source: {
branch: {
name: `${sourceBranchInput}`,
},
},
destination: {
branch: {
name: "dev",
},
},
close_source_branch: false,
reviewers: defaultReviewers
};
const url = `https://api.bitbucket.org/2.0/repositories/${bitbucketRepoOwnerInput}/${bitbucketRepoSlugInput}/pullrequests`;
// make request
return axios.post(url, postData, { headers })
.catch(function (error) {
console.log(error);
});
})