-
Notifications
You must be signed in to change notification settings - Fork 116
/
index.js
37 lines (33 loc) · 1.06 KB
/
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
// File location: index.js
const core = require('@actions/core');
const github = require('@actions/github');
async function run() {
try {
const githubToken = core.getInput('github-token');
const issueMessage = core.getInput('issue-message');
const prMessage = core.getInput('pr-message');
const footer = core.getInput('footer') || '';
const octokit = github.getOctokit(githubToken);
const context = github.context;
if (context.payload.issue) {
// This is an issue
const issueComment = `${issueMessage}\n\n${footer}`;
await octokit.issues.createComment({
...context.repo,
issue_number: context.payload.issue.number,
body: issueComment,
});
} else if (context.payload.pull_request) {
// This is a pull request
const prComment = `${prMessage}\n\n${footer}`;
await octokit.issues.createComment({
...context.repo,
issue_number: context.payload.pull_request.number,
body: prComment,
});
}
} catch (error) {
core.setFailed(error.message);
}
}
run();