Skip to content

Commit 2379a9f

Browse files
authored
feat(plugins/core): support GHES (lowlighter#1188)
1 parent ab85858 commit 2379a9f

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

source/app/action/index.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ function quit(reason) {
146146
"quota.required.search": _quota_required_search,
147147
"notice.release": _notice_releases,
148148
"clean.workflows": _clean_workflows,
149+
"github.api.rest": _github_api_rest,
150+
"github.api.graphql": _github_api_graphql,
149151
...config
150152
} = metadata.plugins.core.inputs.action({core, preset})
151153
const q = {...query, ...(_repo ? {repo: _repo} : null), template}
@@ -175,12 +177,14 @@ function quit(reason) {
175177
conf.settings.token = token
176178
const api = {}
177179
const resources = {}
178-
api.graphql = octokit.graphql.defaults({headers: {authorization: `token ${token}`}})
180+
api.graphql = octokit.graphql.defaults({headers: {authorization: `token ${token}`}, baseUrl: _github_api_graphql || undefined})
179181
info("GitHub GraphQL API", "ok")
180-
const octoraw = github.getOctokit(token)
182+
info("GitHub GraphQL API endpoint", api.graphql.baseUrl)
183+
const octoraw = github.getOctokit(token, {baseUrl: _github_api_rest || undefined})
181184
api.rest = octoraw.rest
182185
api.rest.request = octoraw.request
183186
info("GitHub REST API", "ok")
187+
info("GitHub REST API endpoint", api.rest.baseUrl)
184188
//Apply mocking if needed
185189
if (mocked) {
186190
Object.assign(api, await mocks(api))

source/app/web/instance.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default async function({sandbox = false} = {}) {
5454
console.debug(util.inspect(conf.settings, {depth: Infinity, maxStringLength: 256}))
5555

5656
//Load octokits
57-
const api = {graphql: octokit.graphql.defaults({headers: {authorization: `token ${token}`}}), rest: new OctokitRest.Octokit({auth: token})}
57+
const api = {graphql: octokit.graphql.defaults({headers: {authorization: `token ${token}`}, baseUrl:conf.settings.api?.graphql ?? undefined}), rest: new OctokitRest.Octokit({auth: token, baseUrl: conf.settings.api?.rest ?? undefined})}
5858
//Apply mocking if needed
5959
if (mock)
6060
Object.assign(api, await mocks(api))

source/app/web/settings.example.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/plugins/core/metadata.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,28 @@ inputs:
201201
extras:
202202
- metrics.run.puppeteer.user.js
203203

204+
github_api_rest:
205+
description: |
206+
GitHub REST API endpoint
207+
208+
Can be used to support [GitHub enterprises server](https://github.com/enterprise).
209+
Leave empty to use default endpoint.
210+
type: string
211+
default: ""
212+
example: https://api.github.com
213+
global: yes
214+
215+
github_api_graphql:
216+
description: |
217+
GitHub GraphQL API endpoint
218+
219+
Can be used to support [GitHub enterprises server](https://github.com/enterprise).
220+
Leave empty to use default endpoint.
221+
type: string
222+
default: ""
223+
example: https://api.github.com/graphql
224+
global: yes
225+
204226
config_timezone:
205227
description: |
206228
Timezone for dates

0 commit comments

Comments
 (0)