diff --git a/lib/main.js b/lib/main.js index da00403..2863040 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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' }; diff --git a/src/main.ts b/src/main.ts index 73c7cd9..ccaaf63 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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) {