update code with @action/github 4

This commit is contained in:
marocchino 2021-01-21 07:05:57 +09:00
parent 6843719494
commit 20a3e8289a
No known key found for this signature in database
GPG key ID: AFF521DBDB122570
2 changed files with 9 additions and 9 deletions

View file

@ -29,20 +29,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const github_1 = require("@actions/github");
const github = __importStar(require("@actions/github"));
const comment_1 = require("./comment");
const fs_1 = require("fs");
function run() {
var _a, _b;
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
const number = ((_b = (_a = github_1.context === null || github_1.context === void 0 ? void 0 : github_1.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.number) ||
const number = ((_c = (_b = (_a = github.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 {
const repo = github_1.context.repo;
const repo = github.context.repo;
const message = core.getInput("message", { required: false });
const path = core.getInput("path", { required: false });
const header = core.getInput("header", { required: false }) || "";
@ -50,7 +50,7 @@ function run() {
const recreate = (core.getInput("recreate", { required: false }) || "false") === "true";
const deleteOldComment = (core.getInput("delete", { required: false }) || "false") === "true";
const githubToken = core.getInput("GITHUB_TOKEN", { required: true });
const octokit = new github_1.GitHub(githubToken);
const octokit = github.getOctokit(githubToken);
const previous = yield comment_1.findPreviousComment(octokit, repo, number, header);
if (!message && !path) {
throw { message: 'Either message or path input is required' };

View file

@ -1,11 +1,11 @@
import * as core from "@actions/core";
import { context, GitHub } from "@actions/github";
import * as github from "@actions/github";
import { findPreviousComment, createComment, updateComment, deleteComment } from "./comment";
import { readFileSync } from 'fs';
async function run() {
const number =
context?.payload?.pull_request?.number ||
github.context?.payload?.pull_request?.number ||
+core.getInput("number", { required: false });
if (isNaN(number) || number < 1) {
core.info("no numbers given: skip step");
@ -13,7 +13,7 @@ async function run() {
}
try {
const repo = context.repo;
const repo = github.context.repo;
const message = core.getInput("message", { required: false });
const path = core.getInput("path", { required: false });
const header = core.getInput("header", { required: false }) || "";
@ -21,7 +21,7 @@ async function run() {
const recreate = (core.getInput("recreate", { required: false }) || "false") === "true";
const deleteOldComment = (core.getInput("delete", { required: false }) || "false") === "true";
const githubToken = core.getInput("GITHUB_TOKEN", { required: true });
const octokit = new GitHub(githubToken);
const octokit = github.getOctokit(githubToken);
const previous = await findPreviousComment(octokit, repo, number, header);
if (!message && !path) {