mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-14 20:41:15 +00:00
update code with @action/github 4
This commit is contained in:
parent
6843719494
commit
20a3e8289a
2 changed files with 9 additions and 9 deletions
10
lib/main.js
10
lib/main.js
|
|
@ -29,20 +29,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const github_1 = require("@actions/github");
|
const github = __importStar(require("@actions/github"));
|
||||||
const comment_1 = require("./comment");
|
const comment_1 = require("./comment");
|
||||||
const fs_1 = require("fs");
|
const fs_1 = require("fs");
|
||||||
function run() {
|
function run() {
|
||||||
var _a, _b;
|
var _a, _b, _c;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
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 });
|
+core.getInput("number", { required: false });
|
||||||
if (isNaN(number) || number < 1) {
|
if (isNaN(number) || number < 1) {
|
||||||
core.info("no numbers given: skip step");
|
core.info("no numbers given: skip step");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const repo = github_1.context.repo;
|
const repo = github.context.repo;
|
||||||
const message = core.getInput("message", { required: false });
|
const message = core.getInput("message", { required: false });
|
||||||
const path = core.getInput("path", { required: false });
|
const path = core.getInput("path", { required: false });
|
||||||
const header = core.getInput("header", { 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 recreate = (core.getInput("recreate", { required: false }) || "false") === "true";
|
||||||
const deleteOldComment = (core.getInput("delete", { required: false }) || "false") === "true";
|
const deleteOldComment = (core.getInput("delete", { required: false }) || "false") === "true";
|
||||||
const githubToken = core.getInput("GITHUB_TOKEN", { required: 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);
|
const previous = yield comment_1.findPreviousComment(octokit, repo, number, header);
|
||||||
if (!message && !path) {
|
if (!message && !path) {
|
||||||
throw { message: 'Either message or path input is required' };
|
throw { message: 'Either message or path input is required' };
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import * as core from "@actions/core";
|
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 { findPreviousComment, createComment, updateComment, deleteComment } from "./comment";
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const number =
|
const number =
|
||||||
context?.payload?.pull_request?.number ||
|
github.context?.payload?.pull_request?.number ||
|
||||||
+core.getInput("number", { required: false });
|
+core.getInput("number", { required: false });
|
||||||
if (isNaN(number) || number < 1) {
|
if (isNaN(number) || number < 1) {
|
||||||
core.info("no numbers given: skip step");
|
core.info("no numbers given: skip step");
|
||||||
|
|
@ -13,7 +13,7 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const repo = context.repo;
|
const repo = github.context.repo;
|
||||||
const message = core.getInput("message", { required: false });
|
const message = core.getInput("message", { required: false });
|
||||||
const path = core.getInput("path", { required: false });
|
const path = core.getInput("path", { required: false });
|
||||||
const header = core.getInput("header", { 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 recreate = (core.getInput("recreate", { required: false }) || "false") === "true";
|
||||||
const deleteOldComment = (core.getInput("delete", { required: false }) || "false") === "true";
|
const deleteOldComment = (core.getInput("delete", { required: false }) || "false") === "true";
|
||||||
const githubToken = core.getInput("GITHUB_TOKEN", { required: 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);
|
const previous = await findPreviousComment(octokit, repo, number, header);
|
||||||
|
|
||||||
if (!message && !path) {
|
if (!message && !path) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue