fix: Set the default branch if it's not already set on Github integration (#44332)

Previously, the POST to `/v1/projects/{ref}/branches` didn't work on
free projects, which left some Supabase projects setup without a default
branch. Easy fix for those projects would be to disable/enable the whole
integration.

This PR fixes that so that when the user wants to setup a production
sync, the code checks if there's branches already setup and if not, sets
the selected branch as default.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
This commit is contained in:
Ivan Vasilov
2026-03-30 14:46:32 +02:00
committed by GitHub
parent 514b097021
commit 7bbd7060d3

View File

@@ -323,6 +323,14 @@ export const GitHubIntegrationConnectionForm = ({
gitBranch: data.enableProductionSync ? data.branchName : '',
branchName: data.branchName || 'main',
})
} else {
// if for some reason, the project doesn't have a default branch yet, create it.
createBranch({
projectRef: selectedProject.ref,
gitBranch: data.enableProductionSync ? data.branchName : '',
branchName: data.branchName || 'main',
is_default: true,
})
}
setIsConfirmingBranchChange(false)
@@ -771,7 +779,7 @@ export const GitHubIntegrationConnectionForm = ({
</Button>
)}
<Button
type="default"
type="primary"
htmlType="submit"
disabled={
!hasAccessToGitHubIntegration ||