Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 014b821

Browse files
committed
prettier
1 parent e078a6c commit 014b821

File tree

4 files changed

+55
-25
lines changed

4 files changed

+55
-25
lines changed

action.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
name: 'Wait'
22
description: 'Wait a designated number of milliseconds'
33
inputs:
4-
trigger: # id of input
4+
reaction:
5+
description: 'The emoji "reaction" to put on the comment to indicate that the trigger was detected. For example, "rocket"'
6+
required: false
7+
trigger:
58
description: 'The string to look for in pull-request descriptions and comments'
69
required: true
710
outputs:
8-
triggered: # output will be available to future steps
11+
triggered:
912
description: the string 'true' if the trigger was found
1013
runs:
1114
using: 'node12'

index.js

+35-21
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,67 @@
11
#!/usr/bin/env node
22

3-
const core = require('@actions/core');
4-
const {context, GitHub} = require('@actions/github')
3+
const core = require("@actions/core");
4+
const { context, GitHub } = require("@actions/github");
55

66
async function run() {
7-
const trigger = core.getInput('trigger');
7+
const trigger = core.getInput("trigger");
88
if (!trigger) {
9-
core.setFailed('No `trigger` input given, aborting.')
10-
return
9+
core.setFailed("No `trigger` input given, aborting.");
10+
return;
11+
}
12+
const reaction = core.getInput("reaction");
13+
const { GITHUB_TOKEN } = process.env;
14+
if (reaction && !GITHUB_TOKEN) {
15+
core.setFailed('If "reaction" is supplied, GITHUB_TOKEN is required');
16+
return;
1117
}
1218

13-
if (context.eventName === 'issue_comment' && !context.payload.issue.pull_request) {
19+
if (
20+
context.eventName === "issue_comment" &&
21+
!context.payload.issue.pull_request
22+
) {
1423
// not a pull-request comment, aborting
15-
core.setOutput('triggered', 'false');
16-
return
24+
core.setOutput("triggered", "false");
25+
return;
1726
}
1827

19-
const {owner, repo} = context.repo;
28+
const { owner, repo } = context.repo;
2029

21-
const body = context.eventName === 'issue_comment'
22-
? context.payload.comment.body
23-
: context.payload.pull_request.body;
30+
const body =
31+
context.eventName === "issue_comment"
32+
? context.payload.comment.body
33+
: context.payload.pull_request.body;
2434

2535
if (!body.includes(trigger)) {
26-
core.setOutput('triggered', 'false');
36+
core.setOutput("triggered", "false");
2737
return;
2838
}
2939

30-
core.setOutput('triggered', 'true');
40+
core.setOutput("triggered", "true");
3141

32-
const client = new GitHub(process.env.GITHUB_TOKEN);
33-
if (context.eventName === 'issue_comment') {
42+
if (!reaction) {
43+
return;
44+
}
45+
46+
const client = new GitHub(GITHUB_TOKEN);
47+
if (context.eventName === "issue_comment") {
3448
await client.reactions.createForIssueComment({
3549
owner,
3650
repo,
3751
comment_id: context.payload.comment.id,
38-
content: 'rocket'
39-
})
52+
content: reaction
53+
});
4054
} else {
4155
await client.reactions.createForIssue({
4256
owner,
4357
repo,
4458
issue_number: context.payload.pull_request.number,
45-
content: 'rocket'
59+
content: reaction
4660
});
4761
}
4862
}
4963

5064
run().catch(err => {
51-
console.error(err)
52-
core.setFailed('Unexpected error');
65+
console.error(err);
66+
core.setFailed("Unexpected error");
5367
});

package-lock.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {
7-
"dist": "npx -p @zeit/ncc ncc build index.js"
7+
"dist": "npx -p @zeit/ncc ncc build index.js",
8+
"format": "prettier --write '*.js' --tab-width=4"
89
},
910
"repository": {
1011
"type": "git",
@@ -19,6 +20,8 @@
1920
"homepage": "https://github.com/jaredly/actions-testbed#readme",
2021
"dependencies": {
2122
"@actions/core": "^1.2.0",
22-
"@actions/github": "^1.1.0"
23+
"@actions/github": "^1.1.0",
24+
"prettier": "^1.19.1",
25+
"prettier-cli": "^0.1.0"
2326
}
2427
}

0 commit comments

Comments
 (0)