Skip to content

Commit c7571dd

Browse files
Create index.js
1 parent 5847cd7 commit c7571dd

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/welcome/index.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const core = require('@actions/core');
2+
const github = require('@actions/github');
3+
4+
(async () => {
5+
try {
6+
const githubToken = core.getInput('github-token', { required: true });
7+
const issueMessage = core.getInput('issue-message');
8+
const prMessage = core.getInput('pr-message');
9+
const footer = core.getInput('footer');
10+
11+
// add a comment to the issue or pull request
12+
// @TODO: with a markdown sheild / badge
13+
const client = github.getOctokit(githubToken);
14+
const context = github.context;
15+
16+
if (context.payload.action !== 'opened') {
17+
console.log('No issue / pull request was opened, skipping');
18+
return;
19+
}
20+
21+
const footerTags = `<p>${footer}</p>`;
22+
23+
if (!!context.payload.issue) {
24+
await client.issues.createComment({
25+
owner: context.issue.owner,
26+
repo: context.issue.repo,
27+
issue_number: context.issue.number,
28+
body: issueMessage + footerTags
29+
});
30+
} else {
31+
await client.pulls.createReview({
32+
owner: context.issue.owner,
33+
repo: context.issue.repo,
34+
pull_number: context.issue.number,
35+
body: prMessage + footerTags,
36+
event: 'COMMENT'
37+
});
38+
}
39+
} catch (error) {
40+
core.setFailed(error.message);
41+
}
42+
})();

0 commit comments

Comments
 (0)