Files
supabase/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.schema.ts
Saxon Fletcher ae66a6a9c0 Connect GitHub during project creation (#44884)
<img width="1289" height="863" alt="image"
src="https://github.com/user-attachments/assets/d661f107-b358-4894-8531-80441d60ab91"
/>

GitHub integration is now available on the free plan and so we'd like to
start promoting code-first workflows as much as possible. One way to do
that is to set the tone straight away by asking a user to connecting
their GitHub repository to a project as part of project creation.

This PR: 
- decouples GitHub connection and repo selection into a separate
component we can make use of in integration settings and project
creation.
- Adds new GitHub fields to project creation form and sends them off to
project creation endpoint
- Pre-fills project name based on repo selection 


To test locally:
- Ensure you have GitHub integration set up locally (using ngrok etc)
- Ensure you are on the connected platform branch
- Open create a new project page
- Connect GitHub as part of the creation form and select a repo
- Create the project and wait for status to be healthy
- Check project settings integrations page and ensure repo is connected

Note: 
- this requires changes on the management api end to accept new GitHub
fields
- it might make sense to pull out GitHub connection/authorization from
GitHub repository selection but in the current state they are tied
together.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **New Features**
* GitHub repository selection now available during project creation with
integrated authorization flow
* GitHub connection status and compute availability indicators now
displayed on project dashboard
* Project name auto-populates from selected GitHub repository name when
available

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
2026-05-08 13:52:09 +10:00

66 lines
2.3 KiB
TypeScript

import { z } from 'zod'
import { DEFAULT_MINIMUM_PASSWORD_STRENGTH } from '@/lib/constants'
export const FormSchema = z
.object({
organization: z.string({
required_error: 'Please select an organization',
}),
projectName: z
.string()
.trim()
.min(1, 'Please enter a project name.') // Required field check
.min(3, 'Project name must be at least 3 characters long.') // Minimum length check
.max(64, 'Project name must be no longer than 64 characters.'), // Maximum length check
highAvailability: z.boolean(),
postgresVersion: z.string({
required_error: 'Please enter a Postgres version.',
}),
instanceType: z.string().optional(),
dbRegion: z.string({
required_error: 'Please select a region.',
}),
cloudProvider: z.string({
required_error: 'Please select a cloud provider.',
}),
dbPass: z
.string({ required_error: 'Please enter a database password.' })
.min(1, 'Password is required.'),
dbPassStrength: z
.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(4)])
.default(0),
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(),
postgresVersionSelection: z.string(),
useOrioleDb: z.boolean(),
})
.superRefine(
({ dbPassStrength, dbPassStrengthWarning, highAvailability, cloudProvider }, ctx) => {
if (dbPassStrength < DEFAULT_MINIMUM_PASSWORD_STRENGTH) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['dbPass'],
message: dbPassStrengthWarning || 'Password not secure enough',
})
}
if (highAvailability && cloudProvider !== 'AWS_K8S') {
ctx.addIssue({
code: z.ZodIssueCode.custom,
path: ['cloudProvider'],
message: 'High availability is only supported on AWS (Revamped)',
})
}
}
)
export type CreateProjectForm = z.infer<typeof FormSchema>