generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
42 lines (38 loc) · 1.14 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
38
39
40
41
42
const core = require("@actions/core");
const github = require("@actions/github");
const {linkifyText} = require("./sentry");
// most @actions toolkit packages have async methods
async function run() {
try {
const sentryBase = core.getInput("sentry_base");
const orgSlug = core.getInput("org_slug");
const projectSlugs = new Set(core.getMultilineInput("project_prefixes"));
const octokit = github.getOctokit(core.getInput("github_token"));
const {context} = github;
const {owner, repo} = context.repo;
const {body, number} =
context.payload.pull_request || context.payload.issue;
const newBody = linkifyText(body, sentryBase, orgSlug, projectSlugs);
if (newBody != body) {
const payload = {
owner,
repo,
body: newBody,
};
if (context.eventName === "pull_request") {
await octokit.rest.pulls.update({
...payload,
pull_number: number,
});
} else {
await octokit.rest.issues.update({
...payload,
issue_number: number,
});
}
}
} catch (error) {
core.setFailed(error.message);
}
}
run();