-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
40 lines (32 loc) · 947 Bytes
/
index.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
const core = require('@actions/core');
const github = require('@actions/github');
async function updatePr(token, title, body, pull_number, owner, repo) {
const octokit = github.getOctokit(token);
const req = {
owner: owner,
repo: repo,
pull_number: pull_number
};
if (!!title) {
req['title'] = title;
}
if (!!body) {
req['body'] = body;
}
await octokit.rest.pulls.update(req);
}
async function run() {
try {
const token = core.getInput('token', {required: true});
const title = core.getInput('title', {required: false});
const body = core.getInput('body', {required: false});
const pull_number = github.context.payload.pull_request.number;
const owner = github.context.repo.owner;
const repo = github.context.repo.repo;
await updatePr(token, title, body, pull_number, owner, repo);
} catch (error) {
core.error(error);
core.setFailed(error.message);
}
}
run();