feat: do not fail when no numbers given

This commit is contained in:
marocchino 2019-12-27 08:59:48 +09:00
parent bebd41cac9
commit 5a366cee1f
No known key found for this signature in database
GPG key ID: AFF521DBDB122570
2 changed files with 19 additions and 23 deletions

View file

@ -1,21 +1,20 @@
import * as core from "@actions/core";
import { context, GitHub } from "@actions/github";
import { findPreviousComment, createComment, updateComment } from "./comment";
async function run() {
const number =
context?.payload?.pull_request?.number ||
+core.getInput("number", { required: false });
if (isNaN(number) || number < 1) {
core.info("no numbers given: skip step");
return;
}
try {
const repo = context.repo;
const number =
context?.payload?.pull_request?.number || +core.getInput("number");
const body = core.getInput("message");
const githubToken = core.getInput("GITHUB_TOKEN");
if (isNaN(number)) {
core.setFailed("not found pull request number");
return;
}
if (!body || !githubToken) {
core.setFailed("invalid input: please check your workflow");
return;
}
const body = core.getInput("message", { required: true });
const githubToken = core.getInput("GITHUB_TOKEN", { required: true });
const octokit = new GitHub(githubToken);
const previous = await findPreviousComment(octokit, repo, number);
if (previous) {