Skip to content

Commit b9fd06e

Browse files
committed
[server] Fix automated prebuilds for GitHub Enterprise repositories
1 parent 514520a commit b9fd06e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

components/dashboard/src/projects/NewProject.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,14 @@ function GitProviders(props: {
500500
setErrorMessage(undefined);
501501

502502
const token = await getGitpodService().server.getToken({ host: ap.host });
503-
if (token) {
503+
const isGitHubEnterprise = ap.authProviderType === "GitHub" && ap.host !== "github.com";
504+
if (token && !(isGitHubEnterprise && !token.scopes.includes("public_repo"))) {
504505
props.onHostSelected(ap.host);
505506
return;
506507
}
507508
await openAuthorizeWindow({
508509
host: ap.host,
509-
scopes: ap.requirements?.default,
510+
scopes: isGitHubEnterprise ? ["public_repo"] : ap.requirements?.default,
510511
onSuccess: async () => {
511512
props.onHostSelected(ap.host, true);
512513
},

components/server/src/projects/projects-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class ProjectsService {
148148
const parsedUrl = RepoURL.parseRepoUrl(project.cloneUrl);
149149
const hostContext = parsedUrl?.host ? this.hostContextProvider.get(parsedUrl?.host) : undefined;
150150
const type = hostContext && hostContext.authProvider.info.authProviderType;
151-
if (type === "GitLab" || type === "Bitbucket") {
151+
if (type === "GitLab" || type === "Bitbucket" || (type === "GitHub" && parsedUrl?.host !== "github.com")) {
152152
const repositoryService = hostContext?.services?.repositoryService;
153153
if (repositoryService) {
154154
// Note: For GitLab, we expect .canInstallAutomatedPrebuilds() to always return true, because earlier

0 commit comments

Comments
 (0)