Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: support GitHub enterprise (#7038)

h3n4la430ec320709
diff --git a/frontend/src/components/RepositoryVCSProviderPanel.vue b/frontend/src/components/RepositoryVCSProviderPanel.vue
index 5421aa625d..40ac82abd4 100644
--- a/frontend/src/components/RepositoryVCSProviderPanel.vue
+++ b/frontend/src/components/RepositoryVCSProviderPanel.vue
@@ -113,7 +113,7 @@ const selectVCS = (vcs: ExternalVersionControl) => {
let authorizeUrl = `${vcs.url}/oauth/authorize`;
if (vcs.type === ExternalVersionControl_Type.GITHUB) {
- authorizeUrl = `https://github.com/login/oauth/authorize`;
+ authorizeUrl = `${vcs.url}/login/oauth/authorize`;
} else if (vcs.type === ExternalVersionControl_Type.BITBUCKET) {
authorizeUrl = `https://bitbucket.org/site/oauth2/authorize`;
}
diff --git a/frontend/src/components/VCSProviderBasicInfoPanel.vue b/frontend/src/components/VCSProviderBasicInfoPanel.vue
index fc3cf34b0e..d29d24de20 100644
--- a/frontend/src/components/VCSProviderBasicInfoPanel.vue
+++ b/frontend/src/components/VCSProviderBasicInfoPanel.vue
@@ -4,7 +4,7 @@
{{ $t("gitops.setting.add-git-provider.choose") }}
<span class="text-red-600">*</span>
</div>
- <div class="pt-4 radio-set-row">
+ <div class="flex flex-wrap pt-4 radio-set-row gap-4">
<label class="radio space-x-2">
<input
v-model="config.uiType"
@@ -46,6 +46,19 @@
<img class="h-6 w-auto" src="../assets/github-logo.svg" />
<span class="whitespace-nowrap">GitHub.com</span>
</label>
+ <label class="radio space-x-2">
+ <input
+ v-model="config.uiType"
+ name="GitHub Enterprise"
+ tabindex="-1"
+ type="radio"
+ class="btn"
+ value="GITHUB_ENTERPRISE"
+ @change="changeUIType()"
+ />
+ <img class="h-6 w-auto" src="../assets/github-logo.svg" />
+ <span class="whitespace-nowrap">GitHub Enterprise</span>
+ </label>
<label class="radio space-x-2">
<input
v-model="config.uiType"
@@ -60,21 +73,6 @@
<span class="whitespace-nowrap">Bitbucket.org</span>
</label>
</div>
- <div class="mt-4 relative">
- <div class="relative flex justify-start">
- <span class="pr-2 bg-white text-xs text-control-light">
- {{ $t("common.coming-later") }}
- </span>
- </div>
- </div>
- <div class="mt-2 flex flex-row itmes-center space-x-4 text-xs">
- <div class="flex flex-row space-x-2 items-center text-control">
- <div class="h-5 w-5">
- <img src="../assets/github-logo.svg" />
- </div>
- <label class="whitespace-nowrap">GitHub Enterprise</label>
- </div>
- </div>
<div class="mt-6 pt-6 border-t border-block-border textlabel">
{{ instanceUrlLabel }} <span class="text-red-600">*</span>
</div>
@@ -155,7 +153,11 @@ export default defineComponent({
return "GitLab.com";
}
} else if (props.config.type === ExternalVersionControl_Type.GITHUB) {
- return "GitHub.com";
+ if (props.config.uiType == "GITHUB_COM") {
+ return "GitHub.com";
+ } else if (props.config.uiType === "GITHUB_ENTERPRISE") {
+ return "GitHub Enterprise";
+ }
} else if (props.config.type === ExternalVersionControl_Type.BITBUCKET) {
return "Bitbucket.org";
}
@@ -187,7 +189,11 @@ export default defineComponent({
return "https://gitlab.com";
}
} else if (props.config.type === ExternalVersionControl_Type.GITHUB) {
- return "https://github.com";
+ if (props.config.uiType == "GITHUB_COM") {
+ return "https://github.com";
+ } else if (props.config.uiType == "GITHUB_ENTERPRISE") {
+ return "https://github.companyname.com";
+ }
} else if (props.config.type === ExternalVersionControl_Type.BITBUCKET) {
return "https://bitbucket.org";
}
@@ -197,7 +203,8 @@ export default defineComponent({
// github.com instance url is always https://github.com
const instanceUrlDisabled = computed((): boolean => {
return (
- props.config.type === ExternalVersionControl_Type.GITHUB ||
+ (props.config.type === ExternalVersionControl_Type.GITHUB &&
+ props.config.uiType == "GITHUB_COM") ||
props.config.type === ExternalVersionControl_Type.BITBUCKET ||
(props.config.type === ExternalVersionControl_Type.GITLAB &&
props.config.uiType == "GITLAB_COM")
@@ -255,6 +262,13 @@ export default defineComponent({
props.config.instanceUrl = "https://github.com";
// eslint-disable-next-line vue/no-mutating-props
props.config.name = "GitHub.com";
+ } else if (props.config.uiType == "GITHUB_ENTERPRISE") {
+ // eslint-disable-next-line vue/no-mutating-props
+ props.config.type = ExternalVersionControl_Type.GITHUB;
+ // eslint-disable-next-line vue/no-mutating-props
+ props.config.instanceUrl = "";
+ // eslint-disable-next-line vue/no-mutating-props
+ props.config.name = "Self Hosted GitHub";
} else if (props.config.uiType == "BITBUCKET_ORG") {
// eslint-disable-next-line vue/no-mutating-props
props.config.type = ExternalVersionControl_Type.BITBUCKET;
diff --git a/frontend/src/components/VCSProviderOAuthPanel.vue b/frontend/src/components/VCSProviderOAuthPanel.vue
index 3ed5405ecb..3d7fdb747e 100644
--- a/frontend/src/components/VCSProviderOAuthPanel.vue
+++ b/frontend/src/components/VCSProviderOAuthPanel.vue
@@ -22,6 +22,13 @@
)
}}
</template>
+ <template v-else-if="config.uiType == 'GITHUB_ENTERPRISE'">
+ {{
+ $t(
+ "gitops.setting.add-git-provider.oauth-info.github-register-oauth-application"
+ )
+ }}
+ </template>
<template v-else-if="config.uiType == 'BITBUCKET_ORG'">
{{
$t(
@@ -269,6 +276,81 @@
}}
</li>
</template>
+ <template v-else-if="config.uiType == 'GITHUB_ENTERPRISE'">
+ <li>
+ 1.
+ {{
+ $t(
+ "gitops.setting.add-git-provider.oauth-info.github-login-as-admin"
+ )
+ }}
+ <img class="w-auto" src="../assets/github_admin_settings.png" />
+ </li>
+ <li>
+ 2.
+ {{
+ $t(
+ "gitops.setting.add-git-provider.oauth-info.github-visit-admin-page"
+ )
+ }}
+ </li>
+ <li>
+ 3.
+ {{
+ $t("gitops.setting.add-git-provider.oauth-info.create-oauth-app")
+ }}
+ <div class="m-4 flex justify-center">
+ <dl
+ class="divide-y divide-block-border border border-block-border shadow rounded-lg"
+ >
+ <div class="grid grid-cols-2 gap-4 px-4 py-2">
+ <dt class="text-sm font-medium text-control-light text-right">
+ Application name
+ </dt>
+ <dd class="text-sm text-main">Bytebase</dd>
+ </div>
+ <div class="grid grid-cols-2 gap-4 px-4 py-2 items-center">
+ <dt class="text-sm font-medium text-control-light text-right">
+ Homepage URL
+ </dt>
+ <dd class="text-sm text-main items-center flex">
+ https://bytebase.com
+ <button
+ tabindex="-1"
+ class="ml-1 text-sm font-medium text-control-light hover:bg-gray-100"
+ @click.prevent="copyHomepageURL"
+ >
+ <heroicons-outline:clipboard class="w-6 h-6" />
+ </button>
+ </dd>
+ </div>
+ <div class="grid grid-cols-2 gap-4 px-4 py-2 items-center">
+ <dt class="text-sm font-medium text-control-light text-right">
+ Authorization callback URL
+ </dt>
+ <dd class="text-sm text-main items-center flex">
+ {{ redirectUrl() }}
+ <button
+ tabindex="-1"
+ class="ml-1 text-sm font-medium text-control-light hover:bg-gray-100"
+ @click.prevent="copyRedirectURI"
+ >
+ <heroicons-outline:clipboard class="w-6 h-6" />
+ </button>
+ </dd>
+ </div>
+ </dl>
+ </div>
+ </li>
+ <li>
+ 4.
+ {{
+ $t(
+ "gitops.setting.add-git-provider.oauth-info.github-paste-oauth-info"
+ )
+ }}
+ </li>
+ </template>
<template v-else-if="config.uiType == 'BITBUCKET_ORG'">
<li>
1.
diff --git a/frontend/src/components/VCSSetupWizard.vue b/frontend/src/components/VCSSetupWizard.vue
index 15bc364cd5..f2a8fe5cbd 100644
--- a/frontend/src/components/VCSSetupWizard.vue
+++ b/frontend/src/components/VCSSetupWizard.vue
@@ -163,7 +163,7 @@ const tryChangeStep = (
if (state.currentStep == OAUTH_INFO_STEP && newStep > oldStep) {
let authorizeUrl = `${state.config.instanceUrl}/oauth/authorize`;
if (state.config.type === ExternalVersionControl_Type.GITHUB) {
- authorizeUrl = `https://github.com/login/oauth/authorize`;
+ authorizeUrl = `${state.config.instanceUrl}/login/oauth/authorize`;
} else if (state.config.type === ExternalVersionControl_Type.BITBUCKET) {
authorizeUrl = `https://bitbucket.org/site/oauth2/authorize`;
}
diff --git a/frontend/src/types/vcs.ts b/frontend/src/types/vcs.ts
index f4f512b39a..9469ca1b6f 100644
--- a/frontend/src/types/vcs.ts
+++ b/frontend/src/types/vcs.ts
@@ -10,8 +10,8 @@ export type VCSUIType =
| "GITLAB_SELF_HOST"
| "GITLAB_COM"
| "GITHUB_COM"
+ | "GITHUB_ENTERPRISE"
| "BITBUCKET_ORG";
-
export interface VCSConfig {
type: ExternalVersionControl_Type;
uiType: VCSUIType;