-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy path09-pull-request.js
More file actions
56 lines (50 loc) · 1.25 KB
/
09-pull-request.js
File metadata and controls
56 lines (50 loc) · 1.25 KB
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
48
49
50
51
52
53
54
55
56
/**
* Pull Request
*/
const GitHubClient = require('../libs/GitHubClient.js').GitHubClient;
const contents = require('../libs/features/contents');
const refs = require('../libs/features/refs');
const pullrequests = require('../libs/features/pullrequests');
let githubCli = new GitHubClient({
baseUri:"http://github.at.home/api/v3",
token:process.env.TOKEN_GHITHUB_ENTERPRISE
}
, contents
, refs
, pullrequests
);
let optionsBranch = {
branch: "wip-killer-feature"
, from: "master"
, owner: "ZeiraCorp"
, repository: "toys"
};
let optionsFile = Object.assign({
file:"docs/hello-worls=d.md"
, message: "my hello world file :octocat:"
, content:[
'# Hello World!'
, '> WIP'
, 'this is a test'
, '## And ...'
, '*to be continued* ...'
].join('\n')
}, optionsBranch);
let optionsPR = {
title: "!!!Hey, I've a great idea!"
, body: "It's amazing!"
, head: optionsBranch.branch
, base: optionsBranch.from
, owner: optionsBranch.owner
, repository: optionsBranch.repository
};
githubCli.createBranch(optionsBranch)
.then(res => {
githubCli.createFile(optionsFile)
.then(res => {
githubCli.createPullRequest(optionsPR)
.then(res => {
console.log("PR OK")
})
})
});