Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Connect GitHub during project creation (#44884)

Saxon Fletcherae66a6a9c092
diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts
index fe59e5b5d79..ee5782b85a4 100644
--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts
+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts
@@ -34,6 +34,9 @@ export const FormSchema = z
dbPassStrengthMessage: z.string().default(''),
dbPassStrengthWarning: z.string().default(''),
instanceSize: z.string().optional(),
+ githubRepositoryId: z.string().optional().default(''),
+ githubInstallationId: z.number().optional(),
+ githubRepositoryName: z.string().optional().default(''),
dataApi: z.boolean(),
dataApiDefaultPrivileges: z.boolean(),
enableRlsEventTrigger: z.boolean(),
diff --git a/apps/studio/components/interfaces/ProjectHome/ActivityStats.tsx b/apps/studio/components/interfaces/ProjectHome/ActivityStats.tsx
index d6681798635..f2308ef0ddb 100644
--- a/apps/studio/components/interfaces/ProjectHome/ActivityStats.tsx
+++ b/apps/studio/components/interfaces/ProjectHome/ActivityStats.tsx
@@ -1,24 +1,34 @@
import { useParams } from 'common'
import dayjs from 'dayjs'
-import { Archive, Database, GitBranch } from 'lucide-react'
+import { Archive, Cpu, Database, GitBranch, Github } from 'lucide-react'
import { useMemo } from 'react'
import { cn, Skeleton } from 'ui'
import { TimestampInfo } from 'ui-patterns'
+import { HighAvailabilityBadge } from './HighAvailabilityBadge'
import { ServiceStatus } from './ServiceStatus'
+import { ComputeBadgeWrapper } from '@/components/ui/ComputeBadgeWrapper'
import { SingleStat } from '@/components/ui/SingleStat'
import { useBranchesQuery } from '@/data/branches/branches-query'
import { useBackupsQuery } from '@/data/database/backups-query'
import { DatabaseMigration, useMigrationsQuery } from '@/data/database/migrations-query'
+import { useGitHubConnectionsQuery } from '@/data/integrations/github-connections-query'
+import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'
+import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
+import { PROJECT_STATUS } from '@/lib/constants'
import { EMPTY_ARR } from '@/lib/void'
export const ActivityStats = () => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
+ const { data: organization } = useSelectedOrganizationQuery()
+ const { data: resourceWarnings } = useResourceWarningsQuery({ slug: organization?.slug })
+ const projectResourceWarnings = resourceWarnings?.find((warning) => warning.project === ref)
+ const parentProjectRef = project?.parent_project_ref ?? project?.ref
const { data: branchesData, isPending: isLoadingBranches } = useBranchesQuery({
- projectRef: project?.parent_project_ref ?? project?.ref,
+ projectRef: parentProjectRef,
})
const isDefaultProject = project?.parent_project_ref === undefined
const currentBranch = useMemo(
@@ -61,52 +71,63 @@ export const ActivityStats = () => {
.sort((a, b) => new Date(b.inserted_at).valueOf() - new Date(a.inserted_at).valueOf())[0]
}, [backupsData])
+ const { data: githubConnections, isPending: isLoadingGithubConnections } =
+ useGitHubConnectionsQuery({ organizationId: organization?.id }, { enabled: !!organization?.id })
+ const githubConnection = githubConnections?.find(
+ (connection) => connection.project.ref === parentProjectRef
+ )
+ const isProjectComingUp = [PROJECT_STATUS.COMING_UP, PROJECT_STATUS.UNKNOWN].includes(
+ project?.status ?? PROJECT_STATUS.UNKNOWN
+ )
+ const githubLabelText = githubConnection?.repository.name
+ ? githubConnection.repository.name
+ : isProjectComingUp
+ ? 'Waiting for project...'
+ : 'No repository connected'
+ const integrationsPath = parentProjectRef
+ ? `/project/${parentProjectRef}/settings/integrations`
+ : undefined
+
return (
<div className="@container">
<div className="grid grid-cols-1 @md:grid-cols-2 gap-2 @md:gap-6 flex-wrap">
<ServiceStatus />
<SingleStat
- href={`/project/${ref}/database/migrations`}
- icon={<Database size={18} strokeWidth={1.5} className="text-foreground" />}
- label={<span>Last migration</span>}
- trackingProperties={{
- stat_type: 'migrations',
- stat_value: migrationsData?.length ?? 0,
- }}
+ icon={<Cpu size={18} strokeWidth={1.5} className="text-foreground" />}
+ label={<span>Compute</span>}
value={
- isLoadingMigrations ? (
- <Skeleton className="h-6 w-24" />
- ) : (
- <p className={!!latestMigration ? 'text-foreground' : 'text-foreground-lighter'}>
- {migrationLabelText}
- </p>
- )
+ <div className="flex items-center gap-2 flex-wrap">
+ {project?.infra_compute_size ? (
+ <ComputeBadgeWrapper
+ projectRef={project?.ref}
+ slug={organization?.slug}
+ cloudProvider={project?.cloud_provider}
+ computeSize={project.infra_compute_size}
+ resourceWarnings={projectResourceWarnings}
+ />
+ ) : (
+ <p className="text-foreground-lighter">Unknown</p>
+ )}
+ {project?.high_availability && <HighAvailabilityBadge />}
+ </div>
}
/>
<SingleStat
- href={`/project/${ref}/database/backups/scheduled`}
- icon={<Archive size={18} strokeWidth={1.5} className="text-foreground" />}
- label={<span>Last backup</span>}
- trackingProperties={{
- stat_type: 'backups',
- stat_value: backupsData?.backups?.length ?? 0,
- }}
+ href={integrationsPath}
+ icon={<Github size={18} strokeWidth={1.5} className="text-foreground" />}
+ label={<span>GitHub</span>}
value={
- isLoadingBackups ? (
+ isLoadingGithubConnections ? (
<Skeleton className="h-6 w-24" />
- ) : backupsData?.pitr_enabled ? (
- <p>PITR enabled</p>
- ) : latestBackup ? (
- <TimestampInfo
- className="text-base"
- displayAs="utc"
- label={dayjs(latestBackup.inserted_at).fromNow()}
- utcTimestamp={latestBackup.inserted_at}
- />
) : (
- <p className="text-foreground-lighter">No backups</p>
+ <p
+ className={cn('truncate', !githubConnection && 'text-foreground-lighter')}
+ title={githubLabelText}
+ >
+ {githubLabelText}
+ </p>
)
}
/>
@@ -143,6 +164,51 @@ export const ActivityStats = () => {
)
}
/>
+
+ <SingleStat
+ href={`/project/${ref}/database/migrations`}
+ icon={<Database size={18} strokeWidth={1.5} className="text-foreground" />}
+ label={<span>Last migration</span>}
+ trackingProperties={{
+ stat_type: 'migrations',
+ stat_value: migrationsData?.length ?? 0,
+ }}
+ value={
+ isLoadingMigrations ? (
+ <Skeleton className="h-6 w-24" />
+ ) : (
+ <p className={!!latestMigration ? 'text-foreground' : 'text-foreground-lighter'}>
+ {migrationLabelText}
+ </p>
+ )
+ }
+ />
+
+ <SingleStat
+ href={`/project/${ref}/database/backups/scheduled`}
+ icon={<Archive size={18} strokeWidth={1.5} className="text-foreground" />}
+ label={<span>Last backup</span>}
+ trackingProperties={{
+ stat_type: 'backups',
+ stat_value: backupsData?.backups?.length ?? 0,
+ }}
+ value={
+ isLoadingBackups ? (
+ <Skeleton className="h-6 w-24" />
+ ) : backupsData?.pitr_enabled ? (
+ <p>PITR enabled</p>
+ ) : latestBackup ? (
+ <TimestampInfo
+ className="text-base"
+ displayAs="utc"
+ label={dayjs(latestBackup.inserted_at).fromNow()}
+ utcTimestamp={latestBackup.inserted_at}
+ />
+ ) : (
+ <p className="text-foreground-lighter">No backups</p>
+ )
+ }
+ />
</div>
</div>
)
diff --git a/apps/studio/components/interfaces/ProjectHome/HighAvailabilityBadge.tsx b/apps/studio/components/interfaces/ProjectHome/HighAvailabilityBadge.tsx
index 913a7ac349c..48c1d50d7f3 100644
--- a/apps/studio/components/interfaces/ProjectHome/HighAvailabilityBadge.tsx
+++ b/apps/studio/components/interfaces/ProjectHome/HighAvailabilityBadge.tsx
@@ -15,7 +15,7 @@ export function HighAvailabilityBadge({ size = 'default' }: HighAvailabilityBadg
<HoverCardTrigger asChild>
<div
className={cn(
- 'inline-flex items-center justify-center rounded-md text-center font-mono uppercase',
+ 'relative inline-flex items-center justify-center overflow-hidden rounded-md text-center font-mono uppercase',
'cursor-default whitespace-nowrap font-medium tracking-[0.06em] text-[11px] leading-[1.1] px-[5.5px] py-[3px]',
'transition-all',
'border border-purple-700 dark:border-purple-600/50',
@@ -23,19 +23,19 @@ export function HighAvailabilityBadge({ size = 'default' }: HighAvailabilityBadg
)}
>
{size === 'small' ? 'HA' : 'High Availability'}
+ <span className="animate-badge-shimmer pointer-events-none absolute inset-0 bg-gradient-to-br from-transparent via-white/35 to-transparent blur-md" />
</div>
</HoverCardTrigger>
<HoverCardContent side="bottom" align="start" className="w-72 overflow-hidden p-0">
- <div className="p-2 px-5 text-xs text-foreground-lighter">Multigres</div>
- <Separator />
<div className="h-24 bg-surface-75">
<ServerLightGrid />
</div>
<Separator />
<div className="flex flex-col gap-1 p-3 px-5">
<p className="text-sm text-foreground-light">
- A horizontally scalable Postgres architecture that supports highly-available and
- globally distributed deployments.
+ Driven by <span className="text-foreground">Multigres</span>, a horizontally scalable
+ Postgres architecture that supports highly-available and globally distributed
+ deployments.
</p>
<Link
href={`${DOCS_URL}/guides/deployment/high-availability`}
diff --git a/apps/studio/components/interfaces/ProjectHome/TopSection.tsx b/apps/studio/components/interfaces/ProjectHome/TopSection.tsx
index 842e2a4c8df..0d97223c53b 100644
--- a/apps/studio/components/interfaces/ProjectHome/TopSection.tsx
+++ b/apps/studio/components/interfaces/ProjectHome/TopSection.tsx
@@ -3,26 +3,19 @@ import Link from 'next/link'
import { Badge, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { InstanceConfiguration } from '../Settings/Infrastructure/InfrastructureConfiguration/InstanceConfiguration'
-import { HighAvailabilityBadge } from './HighAvailabilityBadge'
import { ActivityStats } from '@/components/interfaces/ProjectHome/ActivityStats'
import { ProjectConnectionPopover } from '@/components/interfaces/ProjectHome/ProjectConnectionPopover'
import { ProjectPausedState } from '@/components/layouts/ProjectLayout/PausedState/ProjectPausedState'
-import { ComputeBadgeWrapper } from '@/components/ui/ComputeBadgeWrapper'
import { InlineLink } from '@/components/ui/InlineLink'
import { ProjectUpgradeFailedBanner } from '@/components/ui/ProjectUpgradeFailedBanner'
import { useBranchesQuery } from '@/data/branches/branches-query'
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
-import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'
-import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { useIsOrioleDb, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL, PROJECT_STATUS } from '@/lib/constants'
export const TopSection = () => {
const isOrioleDb = useIsOrioleDb()
const { data: project } = useSelectedProjectQuery()
- const { data: organization } = useSelectedOrganizationQuery()
- const { data: resourceWarnings } = useResourceWarningsQuery({ slug: organization?.slug })
- const projectResourceWarnings = resourceWarnings?.find((w) => w.project === project?.ref)
const { data: parentProject } = useProjectDetailQuery({ ref: project?.parent_project_ref })
const { data: branches } = useBranchesQuery({
@@ -61,31 +54,21 @@ export const TopSection = () => {
)}
<div className="flex items-center gap-x-2">
<h1 className="text-3xl">{projectName}</h1>
- <div className="flex items-center gap-x-2">
- {isOrioleDb && (
- <Tooltip>
- <TooltipTrigger asChild>
- <Badge variant="warning">OrioleDB</Badge>
- </TooltipTrigger>
- <TooltipContent side="bottom" align="start" className="max-w-80 text-center">
- This project is using Postgres with OrioleDB which is currently in preview
- and not suitable for production workloads. View our{' '}
- <InlineLink href={`${DOCS_URL}/guides/database/orioledb`}>
- documentation
- </InlineLink>{' '}
- for all limitations.
- </TooltipContent>
- </Tooltip>
- )}
- <ComputeBadgeWrapper
- projectRef={project?.ref}
- slug={organization?.slug}
- cloudProvider={project?.cloud_provider}
- computeSize={project?.infra_compute_size}
- resourceWarnings={projectResourceWarnings}
- />
- {project?.high_availability && <HighAvailabilityBadge />}
- </div>
+ {isOrioleDb && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge variant="warning">OrioleDB</Badge>
+ </TooltipTrigger>
+ <TooltipContent side="bottom" align="start" className="max-w-80 text-center">
+ This project is using Postgres with OrioleDB which is currently in preview and
+ not suitable for production workloads. View our{' '}
+ <InlineLink href={`${DOCS_URL}/guides/database/orioledb`}>
+ documentation
+ </InlineLink>{' '}
+ for all limitations.
+ </TooltipContent>
+ </Tooltip>
+ )}
</div>
<ProjectConnectionPopover projectRef={project?.ref} />
</div>
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
index 851dab9a85c..72e326beee5 100644
--- a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubIntegrationConnectionForm.tsx
@@ -1,8 +1,8 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { AnimatePresence, motion } from 'framer-motion'
-import { ChevronDown, Loader2, PlusIcon, RefreshCw } from 'lucide-react'
-import { useEffect, useMemo, useState } from 'react'
+import { Loader2 } from 'lucide-react'
+import { useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
import { toast } from 'sonner'
import {
@@ -11,20 +11,10 @@ import {
CardContent,
CardFooter,
cn,
- Command_Shadcn_,
- CommandEmpty_Shadcn_,
- CommandGroup_Shadcn_,
- CommandInput_Shadcn_,
- CommandItem_Shadcn_,
- CommandList_Shadcn_,
- CommandSeparator_Shadcn_,
Form,
FormControl,
FormField,
Input_Shadcn_,
- Popover_Shadcn_,
- PopoverContent_Shadcn_,
- PopoverTrigger_Shadcn_,
Switch,
} from 'ui'
import { Admonition } from 'ui-patterns/admonition'
@@ -32,37 +22,25 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
import * as z from 'zod'
+import {
+ GitHubRepositoryField,
+ useGitHubRepositoryOptions,
+} from '@/components/interfaces/Settings/Integrations/GithubIntegration/GitHubRepositoryField'
import { InlineLink } from '@/components/ui/InlineLink'
import { UpgradeToPro } from '@/components/ui/UpgradeToPro'
import { useBranchCreateMutation } from '@/data/branches/branch-create-mutation'
import { useBranchUpdateMutation } from '@/data/branches/branch-update-mutation'
import { useBranchesQuery } from '@/data/branches/branches-query'
-import { useGitHubAuthorizationQuery } from '@/data/integrations/github-authorization-query'
import { useCheckGithubBranchValidity } from '@/data/integrations/github-branch-check-query'
import { useGitHubConnectionCreateMutation } from '@/data/integrations/github-connection-create-mutation'
import { useGitHubConnectionDeleteMutation } from '@/data/integrations/github-connection-delete-mutation'
import { useGitHubConnectionUpdateMutation } from '@/data/integrations/github-connection-update-mutation'
-import { useGitHubRepositoriesQuery } from '@/data/integrations/github-repositories-query'
import type { GitHubConnection } from '@/data/integrations/integrations.types'
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
-import { openInstallGitHubIntegrationWindow } from '@/lib/github'
-import { EMPTY_ARR } from '@/lib/void'
-
-const GITHUB_ICON = (
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 96" className="w-6">
- <title>GitHub icon</title>
- <path
- fill="#ffffff"
- fillRule="evenodd"
- d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
- clipRule="evenodd"
- />
- </svg>
-)
interface GitHubIntegrationConnectionFormProps {
connection?: GitHubConnection
@@ -75,7 +53,6 @@ export const GitHubIntegrationConnectionForm = ({
const { data: selectedOrganization } = useSelectedOrganizationQuery()
const [isConfirmingBranchChange, setIsConfirmingBranchChange] = useState(false)
const [isConfirmingRepoChange, setIsConfirmingRepoChange] = useState(false)
- const [repoComboBoxOpen, setRepoComboboxOpen] = useState(false)
const isParentProject = !selectedProject?.parent_project_ref
const { hasAccess: hasAccessToGitHubIntegration, isLoading: isLoadingEntitlements } =
@@ -92,23 +69,13 @@ export const GitHubIntegrationConnectionForm = ({
'integrations.github_connections'
)
- const { data: gitHubAuthorization, refetch: refetchGitHubAuthorization } =
- useGitHubAuthorizationQuery()
-
const {
- data: githubReposData,
- isPending: isLoadingGitHubRepos,
- refetch: refetchGitHubRepositories,
- } = useGitHubRepositoriesQuery({
- enabled: Boolean(gitHubAuthorization),
- })
-
- const refetchGitHubAuthorizationAndRepositories = () => {
- setTimeout(() => {
- refetchGitHubAuthorization()
- refetchGitHubRepositories()
- }, 2000) // 2 second to delay to let github authorization and repositories to be updated
- }
+ gitHubAuthorization,
+ githubRepos,
+ hasPartialResponseDueToSSO,
+ isLoading: isLoadingRepositoryOptions,
+ refetch: refetchRepositoryOptions,
+ } = useGitHubRepositoryOptions()
const { mutate: updateBranch } = useBranchUpdateMutation({
onSuccess: () => {
@@ -156,19 +123,6 @@ export const GitHubIntegrationConnectionForm = ({
const { mutate: updateConnectionSettings, isPending: isUpdatingConnection } =
useGitHubConnectionUpdateMutation()
- const githubRepos = useMemo(
- () =>
- githubReposData?.repositories?.map((repo) => ({
- id: repo.id.toString(),
- name: repo.name,
- installation_id: repo.installation_id,
- default_branch: repo.default_branch || 'main',
- })) ?? EMPTY_ARR,
- [githubReposData]
- )
-
- const hasPartialResponseDueToSSO = githubReposData?.partial_response_due_to_sso ?? false
-
const prodBranch = existingBranches?.find((branch) => branch.is_default)
// Combined GitHub Settings Form
@@ -224,9 +178,6 @@ export const GitHubIntegrationConnectionForm = ({
const newBranchPerPr = githubSettingsForm.watch('new_branch_per_pr')
const currentRepositoryId = githubSettingsForm.watch('repositoryId')
- // Calculate selected repository based on current form value
- const selectedRepository = githubRepos.find((repo) => repo.id === currentRepositoryId)
-
const handleCreateOrUpdateConnection = async (data: z.infer<typeof GitHubSettingsSchema>) => {
if (!selectedProject?.ref || !selectedOrganization?.id) return
@@ -417,32 +368,12 @@ export const GitHubIntegrationConnectionForm = ({
}
}, [enableProductionSync, githubSettingsForm])
- // Show authorization prompt if not authorized
- if (gitHubAuthorization === null) {
- return (
- <Card>
- <CardContent className="flex flex-col items-center justify-center py-12">
- <p className="text-sm text-center">Authorize with GitHub</p>
- <p className="text-sm text-center text-foreground-light mb-4">
- Connect your GitHub account to access and select repositories for integration.
- </p>
- <Button
- onClick={() => {
- openInstallGitHubIntegrationWindow(
- 'authorize',
- refetchGitHubAuthorizationAndRepositories
- )
- }}
- >
- Authorize GitHub
- </Button>
- </CardContent>
- </Card>
- )
- }
-
const isLoading =
- isLoadingEntitlements || isCreatingConnection || isUpdatingConnection || isDeletingConnection
+ isLoadingEntitlements ||
+ isCreatingConnection ||
+ isUpdatingConnection ||
+ isDeletingConnection ||
+ isLoadingRepositoryOptions
return (
<>
@@ -453,122 +384,34 @@ export const GitHubIntegrationConnectionForm = ({
>
<Card>
<CardContent className="space-y-6">
- {/* Repository Selection */}
- <FormField
- control={githubSettingsForm.control}
+ <GitHubRepositoryField
+ form={githubSettingsForm}
name="repositoryId"
- render={({ field }) => (
- <FormItemLayout
- layout="flex-row-reverse"
- label="GitHub repository"
- description={
- connection
- ? 'Change the connected repository'
- : 'Select the repository to connect to your project'
- }
- >
- <Popover_Shadcn_ open={repoComboBoxOpen} onOpenChange={setRepoComboboxOpen}>
- <PopoverTrigger_Shadcn_ asChild>
- <FormControl>
- <Button
- type="default"
- className="justify-start h-[34px] w-full"
- disabled={isLoadingGitHubRepos}
- loading={isLoadingGitHubRepos}
- icon={
- <div className="bg-black shadow-sm rounded-sm p-1 w-6 h-6 flex justify-center items-center">
- {GITHUB_ICON}
- </div>
- }
- iconRight={
- <span className="grow flex justify-end">
- <ChevronDown />
- </span>
- }
- >
- {selectedRepository || connection
- ? selectedRepository?.name || connection?.repository.name
- : 'Choose GitHub repository'}
- </Button>
- </FormControl>
- </PopoverTrigger_Shadcn_>
- <PopoverContent_Shadcn_ className="p-0 w-80" side="bottom" align="start">
- <Command_Shadcn_>
- <CommandInput_Shadcn_ placeholder="Search repositories..." />
- <CommandList_Shadcn_ className="max-h-[200px]!">
- <CommandEmpty_Shadcn_>No repositories found.</CommandEmpty_Shadcn_>
- {githubRepos.length > 0 ? (
- <CommandGroup_Shadcn_>
- {githubRepos.map((repo, i) => (
- <CommandItem_Shadcn_
- key={repo.id}
- value={`${repo.name.replaceAll('"', '')}-${i}`}
- className="flex gap-2 items-center"
- onSelect={() => {
- field.onChange(repo.id)
- setRepoComboboxOpen(false)
- githubSettingsForm.setValue(
- 'branchName',
- repo.default_branch || 'main'
- )
- }}
- >
- <div className="bg-black shadow-sm rounded-sm p-1 w-5 h-5 flex justify-center items-center">
- {GITHUB_ICON}
- </div>
- <span className="truncate" title={repo.name}>
- {repo.name}
- </span>
- </CommandItem_Shadcn_>
- ))}
- </CommandGroup_Shadcn_>
- ) : null}
- <CommandGroup_Shadcn_>
- <CommandItem_Shadcn_
- className="flex gap-2 items-center cursor-pointer"
- onSelect={() =>
- openInstallGitHubIntegrationWindow(
- 'install',
- refetchGitHubAuthorizationAndRepositories
- )
- }
- >
- <PlusIcon size={16} />
- Add GitHub Repositories
- </CommandItem_Shadcn_>
- </CommandGroup_Shadcn_>
- {hasPartialResponseDueToSSO && (
- <>
- <CommandSeparator_Shadcn_ />
- <CommandGroup_Shadcn_>
- <CommandItem_Shadcn_
- className="flex gap-2 items-start cursor-pointer"
- onSelect={() => {
- openInstallGitHubIntegrationWindow(
- 'authorize',
- refetchGitHubAuthorizationAndRepositories
- )
- }}
- >
- <RefreshCw size={16} className="mt-0.5 shrink-0" />
- <div className="text-xs text-foreground-light">
- Re-authorize GitHub with SSO to show all repositories
- </div>
- </CommandItem_Shadcn_>
- </CommandGroup_Shadcn_>
- </>
- )}
- </CommandList_Shadcn_>
- </Command_Shadcn_>
- </PopoverContent_Shadcn_>
- </Popover_Shadcn_>
- </FormItemLayout>
- )}
+ label="GitHub Repository"
+ layout="flex-row-reverse"
+ description={
+ connection
+ ? 'Change the connected repository'
+ : 'Select the repository to connect to your project'
+ }
+ disabled={
+ (!connection && !canCreateGitHubConnection) ||
+ (connection && !canUpdateGitHubConnection)
+ }
+ selectedRepositoryName={connection?.repository.name}
+ repositories={githubRepos}
+ gitHubAuthorization={gitHubAuthorization}
+ hasPartialResponseDueToSSO={hasPartialResponseDueToSSO}
+ isLoading={isLoadingRepositoryOptions}
+ refetch={refetchRepositoryOptions}
+ onRepositorySelect={(repo) => {
+ githubSettingsForm.setValue('branchName', repo.default_branch || 'main')
+ }}
/>
</CardContent>
<AnimatePresence>
- {!!currentRepositoryId && (
+ {gitHubAuthorization !== null && !!currentRepositoryId && (
<motion.div
initial={{ opacity: 0, y: -16 }}
animate={{ opacity: 1, y: 0 }}
diff --git a/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubRepositoryField.tsx b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubRepositoryField.tsx
new file mode 100644
index 00000000000..e57c55ceea2
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/Integrations/GithubIntegration/GitHubRepositoryField.tsx
@@ -0,0 +1,260 @@
+import { ChevronDown, PlusIcon, RefreshCw } from 'lucide-react'
+import { useMemo, useState, type ComponentProps, type ReactNode } from 'react'
+import type { FieldValues, Path, UseFormReturn } from 'react-hook-form'
+import {
+ Button,
+ Command_Shadcn_,
+ CommandEmpty_Shadcn_,
+ CommandGroup_Shadcn_,
+ CommandInput_Shadcn_,
+ CommandItem_Shadcn_,
+ CommandList_Shadcn_,
+ CommandSeparator_Shadcn_,
+ FormControl,
+ FormField,
+ Popover_Shadcn_,
+ PopoverContent_Shadcn_,
+ PopoverTrigger_Shadcn_,
+} from 'ui'
+import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
+
+import { useGitHubAuthorizationQuery } from '@/data/integrations/github-authorization-query'
+import { useGitHubRepositoriesQuery } from '@/data/integrations/github-repositories-query'
+import { openInstallGitHubIntegrationWindow } from '@/lib/github'
+import { EMPTY_ARR } from '@/lib/void'
+
+export type GitHubRepository = {
+ id: string
+ name: string
+ installation_id: number
+ default_branch: string
+}
+
+export const GITHUB_ICON = (
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 98 96" className="w-5 shrink-0">
+ <title>GitHub icon</title>
+ <path
+ fill="#ffffff"
+ fillRule="evenodd"
+ d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
+ clipRule="evenodd"
+ />
+ </svg>
+)
+
+export const useGitHubRepositoryOptions = () => {
+ const {
+ data: gitHubAuthorization,
+ isPending: isLoadingGitHubAuthorization,
+ refetch: refetchGitHubAuthorization,
+ } = useGitHubAuthorizationQuery()
+
+ const {
+ data: githubReposData,
+ isPending: isLoadingGitHubRepos,
+ refetch: refetchGitHubRepositories,
+ } = useGitHubRepositoriesQuery({
+ enabled: Boolean(gitHubAuthorization),
+ })
+
+ const githubRepos = useMemo<GitHubRepository[]>(
+ () =>
+ githubReposData?.repositories?.map((repo) => ({
+ id: repo.id.toString(),
+ name: repo.name,
+ installation_id: repo.installation_id,
+ default_branch: repo.default_branch || 'main',
+ })) ?? EMPTY_ARR,
+ [githubReposData]
+ )
+
+ const refetchGitHubAuthorizationAndRepositories = () => {
+ setTimeout(() => {
+ refetchGitHubAuthorization()
+ refetchGitHubRepositories()
+ }, 2000)
+ }
+
+ return {
+ gitHubAuthorization,
+ githubRepos,
+ hasPartialResponseDueToSSO: githubReposData?.partial_response_due_to_sso ?? false,
+ isLoading: isLoadingGitHubAuthorization || isLoadingGitHubRepos,
+ refetch: refetchGitHubAuthorizationAndRepositories,
+ }
+}
+
+interface GitHubRepositoryFieldProps<TFormValues extends FieldValues> {
+ form: UseFormReturn<TFormValues>
+ name: Path<TFormValues>
+ label: string
+ description?: ReactNode
+ layout?: ComponentProps<typeof FormItemLayout>['layout']
+ disabled?: boolean
+ selectedRepositoryName?: string
+ installationIdField?: Path<TFormValues>
+ repositoryNameField?: Path<TFormValues>
+ repositories: GitHubRepository[]
+ gitHubAuthorization: unknown | null
+ hasPartialResponseDueToSSO?: boolean
+ isLoading?: boolean
+ placeholder?: string
+ refetch: () => void
+ onConnectClick?: () => void
+ onRepositorySelect?: (repo: GitHubRepository) => void
+}
+
+export const GitHubRepositoryField = <TFormValues extends FieldValues>({
+ form,
+ name,
+ label,
+ description,
+ layout = 'horizontal',
+ disabled = false,
+ selectedRepositoryName,
+ installationIdField,
+ repositoryNameField,
+ repositories,
+ gitHubAuthorization,
+ hasPartialResponseDueToSSO = false,
+ isLoading = false,
+ placeholder = 'Choose GitHub repository',
+ refetch,
+ onConnectClick,
+ onRepositorySelect,
+}: GitHubRepositoryFieldProps<TFormValues>) => {
+ const [isRepoSelectorOpen, setIsRepoSelectorOpen] = useState(false)
+
+ const currentRepositoryId = form.watch(name) as string | undefined
+ const selectedRepository = repositories.find((repo) => repo.id === currentRepositoryId)
+
+ return (
+ <FormField
+ control={form.control}
+ name={name}
+ render={({ field }) => (
+ <FormItemLayout label={label} layout={layout} description={description}>
+ {gitHubAuthorization === null ? (
+ <FormControl>
+ <Button
+ type="default"
+ size="small"
+ htmlType="button"
+ disabled={disabled}
+ onClick={() => {
+ onConnectClick?.()
+ openInstallGitHubIntegrationWindow('authorize', refetch)
+ }}
+ icon={GITHUB_ICON}
+ >
+ Connect GitHub
+ </Button>
+ </FormControl>
+ ) : (
+ <Popover_Shadcn_ open={isRepoSelectorOpen} onOpenChange={setIsRepoSelectorOpen}>
+ <PopoverTrigger_Shadcn_ asChild>
+ <FormControl>
+ <Button
+ type="default"
+ htmlType="button"
+ className="justify-start h-[34px] w-full"
+ disabled={disabled || isLoading}
+ loading={isLoading}
+ icon={GITHUB_ICON}
+ iconRight={
+ <span className="grow flex justify-end">
+ <ChevronDown />
+ </span>
+ }
+ >
+ {selectedRepository?.name ||
+ selectedRepositoryName ||
+ (isLoading ? 'Loading GitHub repositories...' : placeholder)}
+ </Button>
+ </FormControl>
+ </PopoverTrigger_Shadcn_>
+ <PopoverContent_Shadcn_
+ className="p-0"
+ side="bottom"
+ align="start"
+ sameWidthAsTrigger
+ >
+ <Command_Shadcn_>
+ <CommandInput_Shadcn_ placeholder="Search repositories..." />
+ <CommandList_Shadcn_ className="!max-h-[220px]">
+ <CommandEmpty_Shadcn_>No repositories found.</CommandEmpty_Shadcn_>
+ {repositories.length > 0 ? (
+ <CommandGroup_Shadcn_>
+ {repositories.map((repo) => (
+ <CommandItem_Shadcn_
+ key={repo.id}
+ value={`${repo.name.replaceAll('"', '')}-${repo.id}`}
+ className="flex gap-2 items-center"
+ onSelect={() => {
+ field.onChange(repo.id)
+
+ if (installationIdField !== undefined) {
+ form.setValue(installationIdField, repo.installation_id as never, {
+ shouldDirty: true,
+ })
+ }
+
+ if (repositoryNameField !== undefined) {
+ form.setValue(repositoryNameField, repo.name as never, {
+ shouldDirty: true,
+ })
+ }
+
+ onRepositorySelect?.(repo)
+ setIsRepoSelectorOpen(false)
+ }}
+ >
+ {GITHUB_ICON}
+ <span className="truncate" title={repo.name}>
+ {repo.name}
+ </span>
+ </CommandItem_Shadcn_>
+ ))}
+ </CommandGroup_Shadcn_>
+ ) : null}
+ <CommandGroup_Shadcn_>
+ <CommandItem_Shadcn_
+ className="flex gap-2 items-center cursor-pointer"
+ onSelect={() => {
+ setIsRepoSelectorOpen(false)
+ openInstallGitHubIntegrationWindow('install', refetch)
+ }}
+ >
+ <PlusIcon size={16} />
+ Add GitHub Repositories
+ </CommandItem_Shadcn_>
+ </CommandGroup_Shadcn_>
+ {hasPartialResponseDueToSSO && (
+ <>
+ <CommandSeparator_Shadcn_ />
+ <CommandGroup_Shadcn_>
+ <CommandItem_Shadcn_
+ className="flex gap-2 items-start cursor-pointer"
+ onSelect={() => {
+ setIsRepoSelectorOpen(false)
+ openInstallGitHubIntegrationWindow('authorize', refetch)
+ }}
+ >
+ <RefreshCw size={16} className="mt-0.5 shrink-0" />
+ <div className="text-xs text-foreground-light">
+ Re-authorize GitHub with SSO to show all repositories
+ </div>
+ </CommandItem_Shadcn_>
+ </CommandGroup_Shadcn_>
+ </>
+ )}
+ </CommandList_Shadcn_>
+ </Command_Shadcn_>
+ </PopoverContent_Shadcn_>
+ </Popover_Shadcn_>
+ )}
+ </FormItemLayout>
+ )}
+ />
+ )
+}
diff --git a/apps/studio/data/projects/project-create-mutation.test.ts b/apps/studio/data/projects/project-create-mutation.test.ts
new file mode 100644
index 00000000000..7b9cff6d66b
--- /dev/null
+++ b/apps/studio/data/projects/project-create-mutation.test.ts
@@ -0,0 +1,72 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+vi.mock('@/data/fetchers', () => ({
+ post: vi.fn(),
+ handleError: vi.fn((error) => {
+ throw error
+ }),
+}))
+
+describe('project-create-mutation', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ })
+
+ describe('createProject', () => {
+ it('sends GitHub connection fields when provided', async () => {
+ const { post } = await import('@/data/fetchers')
+ const { createProject } = await import('./project-create-mutation')
+
+ const mockPost = post as unknown as ReturnType<typeof vi.fn>
+ mockPost.mockResolvedValueOnce({
+ data: { ref: 'project-ref', organization_slug: 'test-org' },
+ error: null,
+ })
+
+ await createProject({
+ name: 'test-project',
+ organizationSlug: 'test-org',
+ dbPass: 'secret-password',
+ dbRegion: 'West US (North California)',
+ githubInstallationId: 1234,
+ githubRepositoryId: 5678,
+ })
+
+ expect(mockPost).toHaveBeenCalledWith('/platform/projects', {
+ body: expect.objectContaining({
+ name: 'test-project',
+ organization_slug: 'test-org',
+ db_pass: 'secret-password',
+ db_region: 'West US (North California)',
+ github_installation_id: 1234,
+ github_repository_id: 5678,
+ }),
+ })
+ })
+
+ it('does not populate GitHub connection fields when omitted', async () => {
+ const { post } = await import('@/data/fetchers')
+ const { createProject } = await import('./project-create-mutation')
+
+ const mockPost = post as unknown as ReturnType<typeof vi.fn>
+ mockPost.mockResolvedValueOnce({
+ data: { ref: 'project-ref', organization_slug: 'test-org' },
+ error: null,
+ })
+
+ await createProject({
+ name: 'test-project',
+ organizationSlug: 'test-org',
+ dbPass: 'secret-password',
+ dbRegion: 'West US (North California)',
+ })
+
+ expect(mockPost).toHaveBeenCalledWith('/platform/projects', {
+ body: expect.objectContaining({
+ github_installation_id: undefined,
+ github_repository_id: undefined,
+ }),
+ })
+ })
+ })
+})
diff --git a/apps/studio/data/projects/project-create-mutation.ts b/apps/studio/data/projects/project-create-mutation.ts
index 3bd702726de..c4bc3b04b6a 100644
--- a/apps/studio/data/projects/project-create-mutation.ts
+++ b/apps/studio/data/projects/project-create-mutation.ts
@@ -29,6 +29,8 @@ export type ProjectCreateVariables = {
postgresEngine?: PostgresEngine
releaseChannel?: ReleaseChannel
highAvailability?: boolean
+ githubInstallationId?: CreateProjectBody['github_installation_id']
+ githubRepositoryId?: CreateProjectBody['github_repository_id']
}
export async function createProject({
@@ -47,6 +49,8 @@ export async function createProject({
postgresEngine,
releaseChannel,
highAvailability,
+ githubInstallationId,
+ githubRepositoryId,
}: ProjectCreateVariables) {
const body: CreateProjectBody = {
cloud_provider: cloudProvider as CloudProvider,
@@ -66,6 +70,8 @@ export async function createProject({
postgres_engine: postgresEngine,
release_channel: releaseChannel,
high_availability: highAvailability,
+ github_installation_id: githubInstallationId,
+ github_repository_id: githubRepositoryId,
}
const { data, error } = await post(`/platform/projects`, {
diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx
index b3606be43bb..6feae7993dd 100644
--- a/apps/studio/pages/new/[slug].tsx
+++ b/apps/studio/pages/new/[slug].tsx
@@ -38,6 +38,10 @@ import { ProjectCreationFooter } from '@/components/interfaces/ProjectCreation/P
import { ProjectNameInput } from '@/components/interfaces/ProjectCreation/ProjectNameInput'
import { RegionSelector } from '@/components/interfaces/ProjectCreation/RegionSelector'
import { SecurityOptions } from '@/components/interfaces/ProjectCreation/SecurityOptions'
+import {
+ GitHubRepositoryField,
+ useGitHubRepositoryOptions,
+} from '@/components/interfaces/Settings/Integrations/GithubIntegration/GitHubRepositoryField'
import DefaultLayout from '@/components/layouts/DefaultLayout'
import { WizardLayoutWithoutAuth } from '@/components/layouts/WizardLayout'
import Panel from '@/components/ui/Panel'
@@ -58,6 +62,7 @@ import {
useProjectCreateMutation,
} from '@/data/projects/project-create-mutation'
import { useCustomContent } from '@/hooks/custom-content/useCustomContent'
+import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useDataApiRevokeOnCreateDefaultEnabled } from '@/hooks/misc/useDataApiRevokeOnCreateDefault'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
@@ -94,7 +99,14 @@ const Wizard: NextPageWithLayout = () => {
''
)
const { can: isAdmin } = useAsyncCheckPermissions(PermissionAction.CREATE, 'projects')
+ const { can: canCreateGitHubConnection } = useAsyncCheckPermissions(
+ PermissionAction.CREATE,
+ 'integrations.github_connections'
+ )
const showAdvancedConfig = useIsFeatureEnabled('project_creation:show_advanced_config')
+ const { hasAccess: hasAccessToGitHubIntegration } = useCheckEntitlements(
+ 'integrations.github_connections'
+ )
const smartRegionEnabled = useFlag('enableSmartRegion')
const projectCreationDisabled = useFlag('disableProjectCreationAndUpdate')
@@ -137,6 +149,9 @@ const Wizard: NextPageWithLayout = () => {
dbPassStrength: 0,
dbPassStrengthMessage: '',
dbRegion: undefined,
+ githubRepositoryId: '',
+ githubInstallationId: undefined,
+ githubRepositoryName: '',
instanceSize: canChooseInstanceSize ? sizes[0] : undefined,
dataApi: true,
dataApiDefaultPrivileges: !isDataApiRevokeOnCreateDefault,
@@ -150,7 +165,9 @@ const Wizard: NextPageWithLayout = () => {
instanceSize: watchedInstanceSize,
cloudProvider,
dbRegion,
+ githubRepositoryName,
organization,
+ projectName: watchedProjectName,
highAvailability,
} = useWatch({ control: form.control })
@@ -239,6 +256,8 @@ const Wizard: NextPageWithLayout = () => {
: _defaultRegion
const canCreateProject = isAdmin && !freePlanWithExceedingLimits && !hasOutstandingInvoices
+ const canConfigureGitHubOnCreate =
+ canCreateProject && hasAccessToGitHubIntegration && canCreateGitHubConnection
const dbRegionExact = smartRegionToExactRegion(dbRegion ?? '')
@@ -258,6 +277,13 @@ const Wizard: NextPageWithLayout = () => {
)
: false
const shouldShowFreeProjectInfo = !!currentOrg && !isFreePlan && !isUserAtFreeProjectLimit
+ const {
+ gitHubAuthorization,
+ githubRepos,
+ hasPartialResponseDueToSSO,
+ isLoading: isLoadingRepositoryOptions,
+ refetch: refetchRepositoryOptions,
+ } = useGitHubRepositoryOptions()
const {
mutate: createProject,
@@ -319,6 +345,8 @@ const Wizard: NextPageWithLayout = () => {
enableRlsEventTrigger,
postgresVersionSelection,
useOrioleDb,
+ githubInstallationId,
+ githubRepositoryId,
} = values
if (useOrioleDb && !availableOrioleVersion) {
@@ -332,6 +360,10 @@ const Wizard: NextPageWithLayout = () => {
const selectedRegion = smartRegionEnabled
? (smartGroup.find((x) => x.name === dbRegion) ?? specific.find((x) => x.name === dbRegion))
: undefined
+ const parsedGitHubRepositoryId =
+ githubRepositoryId.length > 0 ? Number(githubRepositoryId) : undefined
+ const shouldIncludeGitHubFields =
+ githubInstallationId !== undefined && Number.isFinite(parsedGitHubRepositoryId)
const data: ProjectCreateVariables = {
dbPass,
@@ -355,6 +387,12 @@ const Wizard: NextPageWithLayout = () => {
]
.filter(Boolean)
.join('\n') || undefined,
+ ...(shouldIncludeGitHubFields
+ ? {
+ githubInstallationId,
+ githubRepositoryId: parsedGitHubRepositoryId,
+ }
+ : {}),
}
if (postgresVersion && !postgresVersion.match(/1[2-9]\..*/)) {
@@ -435,6 +473,16 @@ const Wizard: NextPageWithLayout = () => {
}
}, [instanceSize, watchedInstanceSize, setValue])
+ useEffect(() => {
+ if (!githubRepositoryName) return
+ if ((watchedProjectName ?? '').trim().length > 0) return
+
+ const repoName = githubRepositoryName.split('/').at(-1) ?? githubRepositoryName
+ setValue('projectName', repoName.trim(), {
+ shouldValidate: true,
+ })
+ }, [githubRepositoryName, watchedProjectName, setValue])
+
return (
<>
{/* Wizard layouts set the visual header but not the browser tab title. */}
@@ -475,6 +523,38 @@ const Wizard: NextPageWithLayout = () => {
{canCreateProject && (
<>
+ {canConfigureGitHubOnCreate && (
+ <Panel.Content>
+ <GitHubRepositoryField
+ form={form}
+ name="githubRepositoryId"
+ installationIdField="githubInstallationId"
+ repositoryNameField="githubRepositoryName"
+ label="GitHub (optional)"
+ description={
+ <>
+ Ideal for agent-first workflows: update your schema in code, push it
+ to GitHub, and Supabase deploys the changes automatically.{' '}
+ <a
+ href="https://supabase.com/docs/guides/deployment/branching/github-integration"
+ target="_blank"
+ rel="noreferrer noopener"
+ className="text-link"
+ >
+ Learn more
+ </a>
+ </>
+ }
+ disabled={isCreatingNewProject}
+ repositories={githubRepos}
+ gitHubAuthorization={gitHubAuthorization}
+ hasPartialResponseDueToSSO={hasPartialResponseDueToSSO}
+ isLoading={isLoadingRepositoryOptions}
+ refetch={refetchRepositoryOptions}
+ onConnectClick={() => track('project_creation_github_connect_clicked')}
+ />
+ </Panel.Content>
+ )}
<ProjectNameInput form={form} />
<HighAvailabilityInput form={form} />
diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts
index 827883491f9..7f2fe2d91b3 100644
--- a/packages/common/telemetry-constants.ts
+++ b/packages/common/telemetry-constants.ts
@@ -400,6 +400,18 @@ export interface ProjectCreationSimpleVersionSubmittedEvent {
groups: TelemetryGroups
}
+/**
+ * User clicked to connect GitHub during project creation.
+ *
+ * @group Events
+ * @source studio
+ * @page new/{slug}
+ */
+export interface ProjectCreationGithubConnectClickedEvent {
+ action: 'project_creation_github_connect_clicked'
+ groups: Omit<TelemetryGroups, 'project'>
+}
+
/**
* Existing project creation form confirm modal was triggered and opened.
*
@@ -3418,6 +3430,7 @@ export type TelemetryEvent =
| TimezonePickerClickedEvent
| ProjectCreationRlsOptionExperimentExposedEvent
| ProjectCreationDefaultPrivilegesExposedEvent
+ | ProjectCreationGithubConnectClickedEvent
| ProjectCreationSimpleVersionSubmittedEvent
| ProjectCreationSimpleVersionConfirmModalOpenedEvent
| TableApiAccessToggleClickedEvent