-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (30 loc) · 1 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
const core = require('@actions/core');
const github = require('@actions/github');
async function run() {
try {
// Setup Action
const github_token = core.getInput('GITHUB_TOKEN');
const context = github.context;
if (context.payload.pull_request == null) {
core.setFailed('No pull request found.');
return;
}
const octokit = github.getOctokit(github_token);
const pull_request_number = context.payload.pull_request.number;
// Get PR details
const { data: pr_details } = await octokit.pulls.get({
...context.repo,
pull_number: pull_request_number,
});
// Comment on PR
const message = "Thanks for opening a Pull Request @" + pr_details.user.login;
octokit.issues.createComment({
...context.repo,
issue_number: pull_request_number,
body: message
});
} catch (error) {
core.setFailed(error.message);
}
}
run();