forked from everlytic/branch-merge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (26 loc) · 937 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
const github = require('@actions/github')
const core = require('@actions/core');
async function run() {
try {
const token = core.getInput('github_token')
const target_branch = core.getInput('target_branch')
const source_ref = core.getInput('source_ref')
const commit_message_template = core.getInput('commit_message_template')
const octokit = github.getOctokit(token);
const repo = github.context.repo
let commitMessage = commit_message_template
.replace('{source_ref}', source_ref)
.replace('{target_branch}', target_branch);
await octokit.repos.merge({
owner: repo.owner,
repo: repo.repo,
base: target_branch,
head: source_ref,
commit_message: commitMessage
})
} catch (e) {
core.setFailed(e.message)
}
}
// noinspection JSIgnoredPromiseFromCall
run();