-
Notifications
You must be signed in to change notification settings - Fork 186
One-click deployments for Appwrite Sites #2221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
One-click deployments for Appwrite Sites #2221
Conversation
ConsoleProject ID: Sites (2)
Note Appwrite has a Discord community with over 16 000 members. |
import { page } from '$app/state'; | ||
import { page as pageStore } from '$app/stores'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should only use one and the one from the /state
. /stores
one is deprecated.
const urlParams = new URLSearchParams($pageStore.url.search); | ||
const preset = urlParams.get('preset') || 'nextjs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can directly use page.url.searchParams
.
const presetMap = { | ||
nextjs: Framework.Nextjs, | ||
react: Framework.React, | ||
vue: Framework.Vue, | ||
nuxt: Framework.Nuxt, | ||
sveltekit: Framework.Sveltekit, | ||
astro: Framework.Astro, | ||
vite: Framework.Vite, | ||
other: Framework.Other | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use Object.values(Framework)
instead of this manual build up.
if (data.envKeys.length > 0) { | ||
variables = data.envKeys.map((key) => ({ key, value: '', secret: false })); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets move all the init
like logic in onMount
.
const frameworkOptions = [ | ||
{ key: Framework.Nextjs, name: 'Next.js', buildRuntime: BuildRuntime.Node210 }, | ||
{ key: Framework.React, name: 'React', buildRuntime: BuildRuntime.Node210 }, | ||
{ key: Framework.Vue, name: 'Vue', buildRuntime: BuildRuntime.Node210 }, | ||
{ key: Framework.Nuxt, name: 'Nuxt', buildRuntime: BuildRuntime.Node210 }, | ||
{ key: Framework.Sveltekit, name: 'SvelteKit', buildRuntime: BuildRuntime.Node210 }, | ||
{ key: Framework.Astro, name: 'Astro', buildRuntime: BuildRuntime.Node210 }, | ||
{ key: Framework.Vite, name: 'Vite', buildRuntime: BuildRuntime.Node210 }, | ||
{ key: Framework.Other, name: 'Other', buildRuntime: BuildRuntime.Static1 } | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see if we can use the Object.values
and cleanup a bit because all are Node210 except one and 2 name changes.
const promises = variables.map((variable) => | ||
sdk | ||
.forProject(page.params.region, page.params.project) | ||
.sites.createVariable(site.$id, variable.key, variable.value, variable.secret) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meldiron we need a batch for this in the future.
const tagsResponse = await fetch( | ||
`https://api.github.com/repos/${data.repository.owner}/${data.repository.name}/tags` | ||
); | ||
if (tagsResponse.ok) { | ||
const tags = await tagsResponse.json(); | ||
if (tags.length > 0) { | ||
latestTag = tags[0].name; | ||
} else { | ||
addNotification({ | ||
type: 'error', | ||
message: | ||
'No tags found in repository. Please create a tag before deploying.' | ||
}); | ||
return; | ||
} | ||
} else { | ||
addNotification({ | ||
type: 'error', | ||
message: 'Failed to fetch tags from GitHub.' | ||
}); | ||
return; | ||
} | ||
} catch (error) { | ||
addNotification({ | ||
type: 'error', | ||
message: 'Failed to fetch tags from GitHub: ' + error.message | ||
}); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets cleanup by putting the GitHub based tasks in a separate helper function. @Meldiron do we have VCS API method to fetch a specific repo? I don't exactly remember. @atharvadeosthale If we have an SDK, no need for helper and use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the only way to get a repository which is not VCS linked is by using how templates do it, by passing release tags, this is a workaround until I can get appwrite running locally and can make changes to it
…positories, also added ?screenshot search param for repos
The preview deployment is ready. 🟢 Open Preview | Open Build Logs Last updated at: 2025-08-22 21:25:41 CET |
The preview deployment is ready. 🟢 Open Preview | Open Build Logs Last updated at: 2025-08-22 21:25:42 CET |
Note: now also supports one-click deployments for Functions.
This PR adds one-click deployments for Appwrite Sites. It works as follows:
Drawbacks
Parameters accepted
Base URL: /console/deploy
repo
: the GitHub repository URL to deployenv
: environment variable keys, comma separated, example,TEST1,TEST2
. User will fill the values.preset
: if nothing provided, it will be Next.js, or else user can providesveltekit
,vue
,react
,astro
,vite
. Default settings will be automatically appliedinstall
: custom installation command, in case repository has custom needsbuild
: custom build commandoutput
: custom output directoryscreenshot
: screenshot URL for repo modeScreenshots
When the link is visited:
Regular deployment flow
Functions
Just added this features. Following is the base URL
https://[URL]/console/functions/deploy
Drawbacks
Same as sites, need to have a release tag for now
Following are URL search params
repo
- GitHub repository URLruntime
- Runtime ID (e.g., node-18.0, python-3.11, php-8.3, etc.)env
- Comma-separated environment variable keys (e.g., API_KEY,DATABASE_URL)name
- Function name overrideentrypoint
- Entry file to execute (e.g., index.js, main.py, app.php)install
- Install/build command (e.g., npm install, pip install -r requirements.txt)rootDir
- Root directory path (default: ./)