Skip to content

Commit a4f00c7

Browse files
authored
Merge pull request #24 from marocchino/skip-steps
feat: do not fail when no numbers given
2 parents bebd41c + 5a366ce commit a4f00c7

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

lib/main.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,16 @@ const comment_1 = require("./comment");
2222
function run() {
2323
var _a, _b, _c;
2424
return __awaiter(this, void 0, void 0, function* () {
25+
const number = ((_c = (_b = (_a = github_1.context) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.pull_request) === null || _c === void 0 ? void 0 : _c.number) ||
26+
+core.getInput("number", { required: false });
27+
if (isNaN(number) || number < 1) {
28+
core.info("no numbers given: skip step");
29+
return;
30+
}
2531
try {
2632
const repo = github_1.context.repo;
27-
const number = ((_c = (_b = (_a = github_1.context) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.pull_request) === null || _c === void 0 ? void 0 : _c.number) || +core.getInput("number");
28-
const body = core.getInput("message");
29-
const githubToken = core.getInput("GITHUB_TOKEN");
30-
if (isNaN(number)) {
31-
core.setFailed("not found pull request number");
32-
return;
33-
}
34-
if (!body || !githubToken) {
35-
core.setFailed("invalid input: please check your workflow");
36-
return;
37-
}
33+
const body = core.getInput("message", { required: true });
34+
const githubToken = core.getInput("GITHUB_TOKEN", { required: true });
3835
const octokit = new github_1.GitHub(githubToken);
3936
const previous = yield comment_1.findPreviousComment(octokit, repo, number);
4037
if (previous) {

src/main.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import * as core from "@actions/core";
22
import { context, GitHub } from "@actions/github";
33
import { findPreviousComment, createComment, updateComment } from "./comment";
4+
45
async function run() {
6+
const number =
7+
context?.payload?.pull_request?.number ||
8+
+core.getInput("number", { required: false });
9+
if (isNaN(number) || number < 1) {
10+
core.info("no numbers given: skip step");
11+
return;
12+
}
13+
514
try {
615
const repo = context.repo;
7-
const number =
8-
context?.payload?.pull_request?.number || +core.getInput("number");
9-
const body = core.getInput("message");
10-
const githubToken = core.getInput("GITHUB_TOKEN");
11-
if (isNaN(number)) {
12-
core.setFailed("not found pull request number");
13-
return;
14-
}
15-
if (!body || !githubToken) {
16-
core.setFailed("invalid input: please check your workflow");
17-
return;
18-
}
16+
const body = core.getInput("message", { required: true });
17+
const githubToken = core.getInput("GITHUB_TOKEN", { required: true });
1918
const octokit = new GitHub(githubToken);
2019
const previous = await findPreviousComment(octokit, repo, number);
2120
if (previous) {

0 commit comments

Comments
 (0)