From 129be35e9f9f6dd386d4bf8619dfdde8cf27eca3 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 18 May 2026 16:54:27 +0530 Subject: [PATCH] feat: add GitHub App maker to self-hosted Git configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Self-hosted instances without VCS configured now see an inline GitHub App maker in Project Settings → Git instead of a static docs link. Uses the GitHub App manifest flow to pre-configure webhooks, permissions, and callback URLs automatically. Includes CSRF protection via sessionStorage, proper hostname validation, and extracts all required env vars (_APP_VCS_GITHUB_APP_NAME, _APP_VCS_GITHUB_PRIVATE_KEY, _APP_VCS_GITHUB_APP_ID, _APP_VCS_GITHUB_CLIENT_ID, _APP_VCS_GITHUB_CLIENT_SECRET, _APP_VCS_GITHUB_WEBHOOK_SECRET) ready to paste into .env. The connectGit component (used mid-flow in function/site creation) is updated to link back to settings instead of external docs, and migrated to Svelte 5 runes. --- src/lib/components/git/connectGit.svelte | 22 +- src/lib/components/git/gitHubAppMaker.svelte | 320 ++++++++++++++++++ src/lib/components/git/index.ts | 1 + .../settings/updateInstallations.svelte | 13 +- 4 files changed, 333 insertions(+), 23 deletions(-) create mode 100644 src/lib/components/git/gitHubAppMaker.svelte diff --git a/src/lib/components/git/connectGit.svelte b/src/lib/components/git/connectGit.svelte index a44fe5dab2..2368646543 100644 --- a/src/lib/components/git/connectGit.svelte +++ b/src/lib/components/git/connectGit.svelte @@ -5,26 +5,24 @@ import { IconGithub } from '@appwrite.io/pink-icons-svelte'; import { Alert, Card, Empty, Icon, Layout } from '@appwrite.io/pink-svelte'; import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store'; + import { page } from '$app/state'; - export let callbackState: Record = null; + let { callbackState = null }: { callbackState?: Record } = $props(); - let isVcsEnabled = $regionalConsoleVariables?._APP_VCS_ENABLED === true; + const isVcsEnabled = $derived($regionalConsoleVariables?._APP_VCS_ENABLED === true); + + const settingsUrl = $derived( + `/console/project-${page.params.region}-${page.params.project}/settings` + ); {#if !isVcsEnabled && isSelfHosted} - + -

- Before installing Git in a locally hosted Appwrite project, ensure your - environment variables are configured. -

+

Create a GitHub App to enable Git deployments on your self-hosted instance.

- +
diff --git a/src/lib/components/git/gitHubAppMaker.svelte b/src/lib/components/git/gitHubAppMaker.svelte new file mode 100644 index 0000000000..be03c18150 --- /dev/null +++ b/src/lib/components/git/gitHubAppMaker.svelte @@ -0,0 +1,320 @@ + + +{#if exchanging} + + +

Creating your GitHub App...

+
+{:else if credentials} + + +

GitHub App created

+

+ Set these environment variables in the .env file of your Appwrite instance, + then restart your instance. +

+
+ +
+
+ .env + +
+
{envVars}
+
+ +
+ +
+
+{:else} + + +

Create GitHub App

+

+ Registers a GitHub App with the correct webhooks, permissions, and callback URLs + pre-configured using the GitHub App manifest flow. For manual configuration, use the + GitHub app creation form directly. +

+
+ + {#if submitError} +

{submitError}

+ {/if} + + + + + {#if isOrg} + + {/if} +
+ +
+
+
+{/if} + + diff --git a/src/lib/components/git/index.ts b/src/lib/components/git/index.ts index a5cab5eed2..b472801ff2 100644 --- a/src/lib/components/git/index.ts +++ b/src/lib/components/git/index.ts @@ -9,3 +9,4 @@ export { default as ConnectBehaviour } from './connectBehaviour.svelte'; export { default as ProductionBranchFieldset } from './productionBranchFieldset.svelte'; export { default as RepositoryCard } from './repositoryCard.svelte'; export { default as ConnectRepoModal } from './connectRepoModal.svelte'; +export { default as GitHubAppMaker } from './gitHubAppMaker.svelte'; diff --git a/src/routes/(console)/project-[region]-[project]/settings/updateInstallations.svelte b/src/routes/(console)/project-[region]-[project]/settings/updateInstallations.svelte index ca13336779..7be6f61d3a 100644 --- a/src/routes/(console)/project-[region]-[project]/settings/updateInstallations.svelte +++ b/src/routes/(console)/project-[region]-[project]/settings/updateInstallations.svelte @@ -9,7 +9,6 @@ import { isSelfHosted } from '$lib/system'; import { ActionMenu, - Alert, Card, Empty, Icon, @@ -25,6 +24,7 @@ IconPlus, IconXCircle } from '@appwrite.io/pink-icons-svelte'; + import { GitHubAppMaker } from '$lib/components/git'; import DualTimeView from '$lib/components/dualTimeView.svelte'; import { Click, trackEvent } from '$lib/actions/analytics'; import type { ComponentType } from 'svelte'; @@ -172,16 +172,7 @@ {/if}
{:else if isSelfHosted && !isVcsEnabled} - - Before installing Git in a locally hosted Appwrite project, ensure your environment - variables are configured. - - Learn more - - + {:else}