forked from JoseThen/comment-pr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (25 loc) · 888 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
const core = require("@actions/core");
const github = require("@actions/github");
async function run() {
try {
const comment = core.getInput("comment");
const github_token = core.getInput("GITHUB_TOKEN");
const context = github.context;
const owner = context.payload.repository.owner.login;
const repo = context.payload.repository.name;
const pull_number = context.payload.issue.number;
const octokit = new github.GitHub(github_token);
const { data: pullRequest } = await octokit.pulls.get({
owner,
repo,
pull_number
});
const branchName = `${pullRequest.head.ref}-${pullRequest.number}-${context.sha}`;
core.setOutput("test-head", branchName);
core.setOutput("pr-head", pullRequest.head.ref);
core.setOutput("base-head", pullRequest.base.ref);
} catch (error) {
core.setFailed(error.message);
}
}
run();