mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-13 12:11:14 +00:00
Merge pull request #24 from marocchino/skip-steps
feat: do not fail when no numbers given
This commit is contained in:
commit
a4f00c7d52
2 changed files with 19 additions and 23 deletions
19
lib/main.js
19
lib/main.js
|
|
@ -22,19 +22,16 @@ const comment_1 = require("./comment");
|
||||||
function run() {
|
function run() {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
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", { required: false });
|
||||||
|
if (isNaN(number) || number < 1) {
|
||||||
|
core.info("no numbers given: skip step");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const repo = github_1.context.repo;
|
const repo = github_1.context.repo;
|
||||||
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");
|
const body = core.getInput("message", { required: true });
|
||||||
const body = core.getInput("message");
|
const githubToken = core.getInput("GITHUB_TOKEN", { required: true });
|
||||||
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 octokit = new github_1.GitHub(githubToken);
|
const octokit = new github_1.GitHub(githubToken);
|
||||||
const previous = yield comment_1.findPreviousComment(octokit, repo, number);
|
const previous = yield comment_1.findPreviousComment(octokit, repo, number);
|
||||||
if (previous) {
|
if (previous) {
|
||||||
|
|
|
||||||
23
src/main.ts
23
src/main.ts
|
|
@ -1,21 +1,20 @@
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import { context, GitHub } from "@actions/github";
|
import { context, GitHub } from "@actions/github";
|
||||||
import { findPreviousComment, createComment, updateComment } from "./comment";
|
import { findPreviousComment, createComment, updateComment } from "./comment";
|
||||||
|
|
||||||
async function run() {
|
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 {
|
try {
|
||||||
const repo = context.repo;
|
const repo = context.repo;
|
||||||
const number =
|
const body = core.getInput("message", { required: true });
|
||||||
context?.payload?.pull_request?.number || +core.getInput("number");
|
const githubToken = core.getInput("GITHUB_TOKEN", { required: true });
|
||||||
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 octokit = new GitHub(githubToken);
|
const octokit = new GitHub(githubToken);
|
||||||
const previous = await findPreviousComment(octokit, repo, number);
|
const previous = await findPreviousComment(octokit, repo, number);
|
||||||
if (previous) {
|
if (previous) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue