forked from argotorg/solidity
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.ts
More file actions
48 lines (40 loc) · 1.78 KB
/
index.ts
File metadata and controls
48 lines (40 loc) · 1.78 KB
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
43
44
45
46
47
48
import * as core from "@actions/core";
import * as github from "@actions/github";
async function run() {
const token = core.getInput("token");
const octokit = new github.GitHub(token);
const context = github.context;
const comments = await octokit.issues.listComments({
...context.repo,
issue_number: context.payload.pull_request!.number
});
const actionComment = comments.data.find(
comment => comment.body.indexOf("Package: ") >= 0 &&
comment.body.indexOf("Version: ") >= 0 &&
comment.body.indexOf("Action: ") >= 0 &&
comment.body.indexOf("Artifact: ") >= 0 &&
comment.body.indexOf("Commit: ") >= 0
);
if (actionComment) {
let pack = actionComment!.body.substr(actionComment!.body.indexOf("Package: ") + 9)
pack = pack.substr(0, pack.indexOf("\n"));
let version = actionComment!.body.substr(actionComment!.body.indexOf("Version: ") + 9)
version = version.substr(0, version.indexOf("\n"));
let action = actionComment!.body.substr(actionComment!.body.indexOf("Action: ") + 8)
action = action.substr(0, action.indexOf("\n"));
let artifact = actionComment!.body.substr(actionComment!.body.indexOf("Artifact: ") + 10)
artifact = artifact.substr(0, artifact.indexOf("\n"));
let commit = actionComment!.body.substr(actionComment!.body.indexOf("Commit: ") + 8)
core.setOutput("package", pack.trim());
core.setOutput("version", version.trim());
core.setOutput("action", action.trim());
core.setOutput("artifact", artifact.trim());
core.setOutput("commit", commit.trim());
console.log("package", pack.trim());
console.log("version", version.trim());
console.log("action", action.trim());
console.log("artifact", artifact.trim());
console.log("commit", commit.trim());
}
}
run();