Skip to content

Commit

Permalink
Merge pull request #957 from marocchino/remove-base-url
Browse files Browse the repository at this point in the history
⏪️ Rollback base_url option
  • Loading branch information
marocchino authored Apr 21, 2023
2 parents 1926ccb + 4aa1c6a commit f61b6cf
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 45 deletions.
34 changes: 0 additions & 34 deletions __tests__/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
beforeEach(() => {
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_APPEND"] = "false"
process.env["INPUT_RECREATE"] = "false"
Expand All @@ -19,7 +18,6 @@ beforeEach(() => {
afterEach(() => {
jest.resetModules()
delete process.env["GITHUB_REPOSITORY"]
delete process.env["INPUT_BASE_URL"]
delete process.env["INPUT_OWNER"]
delete process.env["INPUT_REPO"]
delete process.env["INPUT_HEADER"]
Expand All @@ -40,29 +38,10 @@ afterEach(() => {
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 () => {
process.env["INPUT_OWNER"] = "jin"
process.env["INPUT_REPO"] = "other"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "jin", repo: "other"},
header: "",
Expand All @@ -81,7 +60,6 @@ test("repo", async () => {
test("header", async () => {
process.env["INPUT_HEADER"] = "header"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "header",
Expand All @@ -100,7 +78,6 @@ test("header", async () => {
test("append", async () => {
process.env["INPUT_APPEND"] = "true"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -119,7 +96,6 @@ test("append", async () => {
test("recreate", async () => {
process.env["INPUT_RECREATE"] = "true"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -138,7 +114,6 @@ test("recreate", async () => {
test("delete", async () => {
process.env["INPUT_DELETE"] = "true"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -157,7 +132,6 @@ test("delete", async () => {
test("hideOldComment", async () => {
process.env["INPUT_HIDE"] = "true"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -176,7 +150,6 @@ test("hideOldComment", async () => {
test("hideAndRecreate", async () => {
process.env["INPUT_HIDE_AND_RECREATE"] = "true"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -195,7 +168,6 @@ test("hideAndRecreate", async () => {
test("hideClassify", async () => {
process.env["INPUT_HIDE_CLASSIFY"] = "OFF_TOPIC"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -214,7 +186,6 @@ test("hideClassify", async () => {
test("hideDetails", async () => {
process.env["INPUT_HIDE_DETAILS"] = "true"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -234,7 +205,6 @@ describe("path", () => {
test("when exists return content of a file", async () => {
process.env["INPUT_PATH"] = "./__tests__/assets/result"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -254,7 +224,6 @@ describe("path", () => {
test("glob match files", async () => {
process.env["INPUT_PATH"] = "./__tests__/assets/*"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -276,7 +245,6 @@ describe("path", () => {
test("when not exists return null string", async () => {
process.env["INPUT_PATH"] = "./__tests__/assets/not_exists"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -297,7 +265,6 @@ describe("path", () => {
test("message", async () => {
process.env["INPUT_MESSAGE"] = "hello there"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand All @@ -317,7 +284,6 @@ test("message", async () => {
test("ignore_empty", async () => {
process.env["INPUT_IGNORE_EMPTY"] = "true"
expect(require("../src/config")).toMatchObject({
baseUrl: "https://api.github.com",
pullRequestNumber: expect.any(Number),
repo: {owner: "marocchino", repo: "stick-pull-request-comment"},
header: "",
Expand Down
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ github-token:
pull-requests-reason: to create or update PR comment

inputs:
base_url:
description: "base api url. default to: ${{ env.GITHUB_API_URL }}"
default: "${{ env.GITHUB_API_URL }}"
required: false
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."
default: ""
Expand Down
5 changes: 2 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const pullRequestNumber =
context?.payload?.pull_request?.number ||
+core.getInput("number", {required: false})

export const baseUrl = core.getInput("base_url", {required: true})
export const repo = buildRepo()
export const header = core.getInput("header", {required: false})
export const append = core.getBooleanInput("append", {required: true})
Expand Down
3 changes: 1 addition & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as github from "@actions/github"
import {
append,
getBody,
baseUrl,
deleteOldComment,
githubToken,
header,
Expand Down Expand Up @@ -57,7 +56,7 @@ async function run(): Promise<undefined> {
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(
octokit,
repo,
Expand Down

0 comments on commit f61b6cf

Please sign in to comment.