mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-14 20:41:15 +00:00
Merge pull request #957 from marocchino/remove-base-url
⏪️ Rollback base_url option
This commit is contained in:
commit
f61b6cf21e
6 changed files with 4 additions and 45 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env["GITHUB_REPOSITORY"] = "marocchino/stick-pull-request-comment"
|
process.env["GITHUB_REPOSITORY"] = "marocchino/stick-pull-request-comment"
|
||||||
process.env["INPUT_BASE_URL"] = "https://api.github.com"
|
|
||||||
process.env["INPUT_NUMBER"] = "123"
|
process.env["INPUT_NUMBER"] = "123"
|
||||||
process.env["INPUT_APPEND"] = "false"
|
process.env["INPUT_APPEND"] = "false"
|
||||||
process.env["INPUT_RECREATE"] = "false"
|
process.env["INPUT_RECREATE"] = "false"
|
||||||
|
|
@ -19,7 +18,6 @@ beforeEach(() => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetModules()
|
jest.resetModules()
|
||||||
delete process.env["GITHUB_REPOSITORY"]
|
delete process.env["GITHUB_REPOSITORY"]
|
||||||
delete process.env["INPUT_BASE_URL"]
|
|
||||||
delete process.env["INPUT_OWNER"]
|
delete process.env["INPUT_OWNER"]
|
||||||
delete process.env["INPUT_REPO"]
|
delete process.env["INPUT_REPO"]
|
||||||
delete process.env["INPUT_HEADER"]
|
delete process.env["INPUT_HEADER"]
|
||||||
|
|
@ -40,29 +38,10 @@ afterEach(() => {
|
||||||
delete process.env["INPUT_FOLLOW_SYMBOLIC_LINKS"]
|
delete process.env["INPUT_FOLLOW_SYMBOLIC_LINKS"]
|
||||||
})
|
})
|
||||||
|
|
||||||
test("baseUrl", async () => {
|
|
||||||
process.env["INPUT_BASE_URL"] = "https://repo.yourcompany.com"
|
|
||||||
expect(require("../src/config")).toMatchObject({
|
|
||||||
baseUrl: "https://repo.yourcompany.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
|
||||||
header: "",
|
|
||||||
append: false,
|
|
||||||
recreate: false,
|
|
||||||
deleteOldComment: false,
|
|
||||||
hideOldComment: false,
|
|
||||||
hideAndRecreate: false,
|
|
||||||
hideClassify: "OUTDATED",
|
|
||||||
hideDetails: false,
|
|
||||||
githubToken: "some-token",
|
|
||||||
ignoreEmpty: false
|
|
||||||
})
|
|
||||||
})
|
|
||||||
test("repo", async () => {
|
test("repo", async () => {
|
||||||
process.env["INPUT_OWNER"] = "jin"
|
process.env["INPUT_OWNER"] = "jin"
|
||||||
process.env["INPUT_REPO"] = "other"
|
process.env["INPUT_REPO"] = "other"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "jin", repo: "other"},
|
repo: {owner: "jin", repo: "other"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -81,7 +60,6 @@ test("repo", async () => {
|
||||||
test("header", async () => {
|
test("header", async () => {
|
||||||
process.env["INPUT_HEADER"] = "header"
|
process.env["INPUT_HEADER"] = "header"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "header",
|
header: "header",
|
||||||
|
|
@ -100,7 +78,6 @@ test("header", async () => {
|
||||||
test("append", async () => {
|
test("append", async () => {
|
||||||
process.env["INPUT_APPEND"] = "true"
|
process.env["INPUT_APPEND"] = "true"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -119,7 +96,6 @@ test("append", async () => {
|
||||||
test("recreate", async () => {
|
test("recreate", async () => {
|
||||||
process.env["INPUT_RECREATE"] = "true"
|
process.env["INPUT_RECREATE"] = "true"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -138,7 +114,6 @@ test("recreate", async () => {
|
||||||
test("delete", async () => {
|
test("delete", async () => {
|
||||||
process.env["INPUT_DELETE"] = "true"
|
process.env["INPUT_DELETE"] = "true"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -157,7 +132,6 @@ test("delete", async () => {
|
||||||
test("hideOldComment", async () => {
|
test("hideOldComment", async () => {
|
||||||
process.env["INPUT_HIDE"] = "true"
|
process.env["INPUT_HIDE"] = "true"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -176,7 +150,6 @@ test("hideOldComment", async () => {
|
||||||
test("hideAndRecreate", async () => {
|
test("hideAndRecreate", async () => {
|
||||||
process.env["INPUT_HIDE_AND_RECREATE"] = "true"
|
process.env["INPUT_HIDE_AND_RECREATE"] = "true"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -195,7 +168,6 @@ test("hideAndRecreate", async () => {
|
||||||
test("hideClassify", async () => {
|
test("hideClassify", async () => {
|
||||||
process.env["INPUT_HIDE_CLASSIFY"] = "OFF_TOPIC"
|
process.env["INPUT_HIDE_CLASSIFY"] = "OFF_TOPIC"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -214,7 +186,6 @@ test("hideClassify", async () => {
|
||||||
test("hideDetails", async () => {
|
test("hideDetails", async () => {
|
||||||
process.env["INPUT_HIDE_DETAILS"] = "true"
|
process.env["INPUT_HIDE_DETAILS"] = "true"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -234,7 +205,6 @@ describe("path", () => {
|
||||||
test("when exists return content of a file", async () => {
|
test("when exists return content of a file", async () => {
|
||||||
process.env["INPUT_PATH"] = "./__tests__/assets/result"
|
process.env["INPUT_PATH"] = "./__tests__/assets/result"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -254,7 +224,6 @@ describe("path", () => {
|
||||||
test("glob match files", async () => {
|
test("glob match files", async () => {
|
||||||
process.env["INPUT_PATH"] = "./__tests__/assets/*"
|
process.env["INPUT_PATH"] = "./__tests__/assets/*"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -276,7 +245,6 @@ describe("path", () => {
|
||||||
test("when not exists return null string", async () => {
|
test("when not exists return null string", async () => {
|
||||||
process.env["INPUT_PATH"] = "./__tests__/assets/not_exists"
|
process.env["INPUT_PATH"] = "./__tests__/assets/not_exists"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -297,7 +265,6 @@ describe("path", () => {
|
||||||
test("message", async () => {
|
test("message", async () => {
|
||||||
process.env["INPUT_MESSAGE"] = "hello there"
|
process.env["INPUT_MESSAGE"] = "hello there"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
@ -317,7 +284,6 @@ test("message", async () => {
|
||||||
test("ignore_empty", async () => {
|
test("ignore_empty", async () => {
|
||||||
process.env["INPUT_IGNORE_EMPTY"] = "true"
|
process.env["INPUT_IGNORE_EMPTY"] = "true"
|
||||||
expect(require("../src/config")).toMatchObject({
|
expect(require("../src/config")).toMatchObject({
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
pullRequestNumber: expect.any(Number),
|
pullRequestNumber: expect.any(Number),
|
||||||
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
|
||||||
header: "",
|
header: "",
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,6 @@ github-token:
|
||||||
pull-requests-reason: to create or update PR comment
|
pull-requests-reason: to create or update PR comment
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
base_url:
|
|
||||||
description: "base api url. default to: ${{ env.GITHUB_API_URL }}"
|
|
||||||
default: "${{ env.GITHUB_API_URL }}"
|
|
||||||
required: false
|
|
||||||
header:
|
header:
|
||||||
description: "Header to determine if the comment is to be updated, not shown on screen. It can be used when you want to add multiple comments independently at the same time."
|
description: "Header to determine if the comment is to be updated, not shown on screen. It can be used when you want to add multiple comments independently at the same time."
|
||||||
default: ""
|
default: ""
|
||||||
|
|
|
||||||
5
dist/index.js
generated
vendored
5
dist/index.js
generated
vendored
|
|
@ -207,14 +207,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
};
|
};
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getBody = exports.ignoreEmpty = exports.githubToken = exports.hideOldComment = exports.onlyUpdateComment = exports.onlyCreateComment = exports.deleteOldComment = exports.hideClassify = exports.hideAndRecreate = exports.recreate = exports.hideDetails = exports.append = exports.header = exports.repo = exports.baseUrl = exports.pullRequestNumber = void 0;
|
exports.getBody = exports.ignoreEmpty = exports.githubToken = exports.hideOldComment = exports.onlyUpdateComment = exports.onlyCreateComment = exports.deleteOldComment = exports.hideClassify = exports.hideAndRecreate = exports.recreate = exports.hideDetails = exports.append = exports.header = exports.repo = exports.pullRequestNumber = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const github_1 = __nccwpck_require__(5438);
|
const github_1 = __nccwpck_require__(5438);
|
||||||
const fs_1 = __nccwpck_require__(7147);
|
const fs_1 = __nccwpck_require__(7147);
|
||||||
const glob_1 = __nccwpck_require__(8090);
|
const glob_1 = __nccwpck_require__(8090);
|
||||||
exports.pullRequestNumber = ((_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) ||
|
exports.pullRequestNumber = ((_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) ||
|
||||||
+core.getInput("number", { required: false });
|
+core.getInput("number", { required: false });
|
||||||
exports.baseUrl = core.getInput("base_url", { required: true });
|
|
||||||
exports.repo = buildRepo();
|
exports.repo = buildRepo();
|
||||||
exports.header = core.getInput("header", { required: false });
|
exports.header = core.getInput("header", { required: false });
|
||||||
exports.append = core.getBooleanInput("append", { required: true });
|
exports.append = core.getBooleanInput("append", { required: true });
|
||||||
|
|
@ -345,7 +344,7 @@ function run() {
|
||||||
if (config_1.hideOldComment && config_1.hideAndRecreate) {
|
if (config_1.hideOldComment && config_1.hideAndRecreate) {
|
||||||
throw new Error("hide and hide_and_recreate cannot be both set to true");
|
throw new Error("hide and hide_and_recreate cannot be both set to true");
|
||||||
}
|
}
|
||||||
const octokit = github.getOctokit(config_1.githubToken, { baseUrl: config_1.baseUrl });
|
const octokit = github.getOctokit(config_1.githubToken);
|
||||||
const previous = yield (0, comment_1.findPreviousComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.header);
|
const previous = yield (0, comment_1.findPreviousComment)(octokit, config_1.repo, config_1.pullRequestNumber, config_1.header);
|
||||||
if (config_1.deleteOldComment) {
|
if (config_1.deleteOldComment) {
|
||||||
if (previous) {
|
if (previous) {
|
||||||
|
|
|
||||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
|
|
@ -8,7 +8,6 @@ export const pullRequestNumber =
|
||||||
context?.payload?.pull_request?.number ||
|
context?.payload?.pull_request?.number ||
|
||||||
+core.getInput("number", {required: false})
|
+core.getInput("number", {required: false})
|
||||||
|
|
||||||
export const baseUrl = core.getInput("base_url", {required: true})
|
|
||||||
export const repo = buildRepo()
|
export const repo = buildRepo()
|
||||||
export const header = core.getInput("header", {required: false})
|
export const header = core.getInput("header", {required: false})
|
||||||
export const append = core.getBooleanInput("append", {required: true})
|
export const append = core.getBooleanInput("append", {required: true})
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import * as github from "@actions/github"
|
||||||
import {
|
import {
|
||||||
append,
|
append,
|
||||||
getBody,
|
getBody,
|
||||||
baseUrl,
|
|
||||||
deleteOldComment,
|
deleteOldComment,
|
||||||
githubToken,
|
githubToken,
|
||||||
header,
|
header,
|
||||||
|
|
@ -57,7 +56,7 @@ async function run(): Promise<undefined> {
|
||||||
throw new Error("hide and hide_and_recreate cannot be both set to true")
|
throw new Error("hide and hide_and_recreate cannot be both set to true")
|
||||||
}
|
}
|
||||||
|
|
||||||
const octokit = github.getOctokit(githubToken, {baseUrl})
|
const octokit = github.getOctokit(githubToken)
|
||||||
const previous = await findPreviousComment(
|
const previous = await findPreviousComment(
|
||||||
octokit,
|
octokit,
|
||||||
repo,
|
repo,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue