Skip to content

Sites

Deploy from Git

Learn to version and update your Appwrite Sites' code with deployments.

8 min read

Raw

Appwrite Sites allows you to host and deploy websites directly within the Appwrite platform. Each site can have many deployments, which can be thought of as versions of the web application.

With Appwrite Sites, you can seamlessly deploy updates from Git repositories, enabling you to track changes to your web app as part of your development workflow. This versioning approach ensures that your site stays up-to-date and your deployment process is fully integrated with your source control, streamlining collaboration and updates.

Create deployment

The recommended way to manage your Appwrite Sites deployments is to use a version control system like Git. This offers simple versioning and collaboration that will easily fit into the rest of your development workflow.

You can only use Git deployment for Appwrite Sites connected to Git. Create a new site with GitHub or connect your existing site to a Git repository in your site’s Settings > Version control (Git).

Git repository
Git repository

  1. Using Git, checkout to the branch you configured as the production branch when creating the Appwrite Site.
  2. Create a new commit.
  3. Push the commit.
  4. A new deployment will be automatically created, built, and activated.

Pushes deploy automatically while Deploy on push is on in the site's Git automation settings.

Commits to the production branch

When you push a commit to the production branch, usually main, a new deployment is created, built, and activated. This means the new deployments immediately replace the current active deployment and can be used on your site’s primary domain.

Commits to other branches

When you push a commit to a branch other than the production branch, a new deployment is created, but it is not activated. A preview link is generated to test this deployment; however, only authorized users, i.e., members of your Appwrite organization, can access this link.

Git configuration

If you need to update your Git configuration, navigate to Sites > your site > Settings > Version control (Git).

Git automation

Git automation controls what Appwrite does when you push to the connected repository. Once your site is connected to a repository, open its Settings > Version control (Git) and find the Git automation card.

Git automation card in the Appwrite Console
Git automation card in the Appwrite Console

The card holds the Production branch and three switches, all on by default:

SwitchAPI parameterWhen it's on
Deploy on pushproviderDeploymentsEvery push that matches your build triggers creates a deployment. Pushes to the production branch activate it, and other branches get a preview link.
Post build summariesproviderCommentsAppwrite posts one comment on each pull request with the build status and preview link, and updates it as builds finish.
Report commit statusproviderStatusesAppwrite reports each build on its commit as building, passed, or failed. On GitHub, it adds a check run. On Entire, it adds a check run and a deployment entry. On GitLab and Gitea, it sets a commit status, and on Bitbucket, a build status.

Changes apply from the next push, without a redeploy.

Deploy on push

When Deploy on push is off, pushes no longer create deployments, including preview deployments, and your site keeps serving its active deployment. The repository stays connected, so you can deploy a branch whenever you choose: open the site's Deployments tab, click Create deployment, and select Git. You pick the branch and whether to activate the deployment when it finishes building.

While it's off, the Console disables Production branch and Post build summaries, because a deployment you create yourself has no pull request and decides for itself whether to go live. Report commit status still works for the commits you deploy.

Post build summaries

Turn off Post build summaries to keep Appwrite's comment out of pull requests. Preview deployments are still created, and if Report commit status stays on, each commit still shows whether the build passed.

Appwrite posts the summary when a pull request is opened or reopened, so turning the switch on doesn't add one to a pull request that's already open. Entire doesn't get build summaries.

Report commit status

Turn off Report commit status to stop Appwrite from adding checks, statuses, and deployment entries to your commits.

Silent mode

You can turn on Silent mode when you create a site from a repository. Silent mode turns off build summaries and commit statuses, whatever the switches say, and the Git automation card shows both as off while it's on. Saving the card turns silent mode off and saves both switches as the card shows them, so turn on the ones you want before you click Update. Silent mode doesn't affect Deploy on push.

Configure Git automation with a Server SDK

Pass providerDeployments, providerComments, and providerStatuses when you create or update a site. Settings you leave out of an update keep their current values.

const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>') // Your project ID
.setKey('<API_KEY>'); // Your secret API key
const sites = new sdk.Sites(client);
// Stop deploying on push, and deploy branches by hand instead
await sites.update({
siteId: '<SITE_ID>',
name: '<NAME>', // name and framework are required by update
framework: sdk.Framework.Nextjs,
providerDeployments: false
});

To deploy a branch or commit while Deploy on push is off, call sites.createVcsDeployment() with type set to branch or commit, the branch name or commit hash as reference, and activate set to true to make it live once it builds.

Build triggers

Build triggers control which Git changes create automatic deployments. You can configure branch filters and path filters with glob patterns.

Branch filters match branch names. Add patterns to limit automatic deployments to specific branches.

Plain text
main
staging
preview/**

Path filters match files changed in a commit or pull request. Leave this field empty to create deployments for all file changes, or add patterns to deploy only when specific files change.

Plain text
apps/web/**
packages/ui/**
!docs/**

Use these formats to write glob patterns.

PatternWhat it doesExampleMatches
mainMatches exact textmainmain
*Matches within one path segmentrelease/*release/1.0
**Matches across nested path segmentspreview/**preview/test, preview/team/test
?Matches one character in one path segmentv?.?v1.0, v2.5
[abc]Matches one character from a set[Mm]ainmain, Main
[a-z]Matches one character in a rangerelease/[0-9]*release/1.0
\Escapes a special characterfile\?.txtfile?.txt
!Excludes matching branches or paths!docs/**Excludes changes under docs/

Skip a deployment

To push a commit without creating a deployment, add [skip appwrite] or [skip ci] to the commit message. [skip appwrite] skips only the Appwrite deployment. [skip ci] is also recognized by GitHub Actions and most other CI tools, so it skips those workflows too.

Plain text
docs: update readme [skip appwrite]

Install command

The install command of your site allow you to install your site’s dependencies. You can specify custom install scripts such as ones that let you configure your npm command with options or use an alternative package manager such as pnpm or yarn.

Build command

The build command of your site allow you to create a build of the site ready for output. You can specify custom build scripts, customize your npm command options, or use alternative package managers.

Output directory

The output directory will contain the files generated by your site's build command. The contents of this directory will be available to view on your site's public URL.

Monorepos

Appwrite Sites can deploy server-rendered apps from npm, pnpm, and Bun workspaces. Appwrite installs and builds the workspace from the root of the repository, then deploys your app's build output together with its dependencies and the workspace packages it imports. Code from the other apps in the repository isn't included in the deployment.

Monorepo deployments work with every JavaScript framework that Appwrite Sites renders on the server: Next.js, Nuxt, Astro, SvelteKit, Remix, TanStack Start, Angular, and Analog.

Here's an example pnpm workspace, with a Next.js app in apps/web that imports a shared package from packages/ui:

Plain text
acme/
├── apps/
│ ├── web/ # the Next.js app to deploy
│ └── docs/
├── packages/
│ └── ui/
├── package.json
├── pnpm-lock.yaml
└── pnpm-workspace.yaml

These are the settings to use, either when creating the site or later in its settings:

  • Root directory: ./, the root of the repository. The lockfile and the workspace config need to be inside the root directory.
  • Framework: your app's framework, selected by hand. Automatic detection reads the package.json and config files in the root directory, and in a monorepo those belong to the workspace rather than your app.
  • Install command: a command that installs the whole workspace, such as pnpm install.
  • Build command: a command that builds only your app, such as pnpm --filter web build, where web is the name field in your app's package.json.
  • Output directory: the path to your app's build output from the root of the repository, such as ./apps/web/.next.

The install and build commands for each package manager look like this:

Package managerInstall commandBuild command
npmnpm installnpm run build --workspace web
pnpmpnpm installpnpm --filter web build
Bunbun installbun run --filter web build

Workspace packages that have their own build step need to be built in the same command.

To deploy several apps from one repository, create one site per app, each with its own build command and output directory. Path filters on each site keep it from deploying when only another app changes, for example apps/web/**, packages/**, and your lockfile. Listing the individual packages the app imports, instead of packages/**, narrows this further.

These setups aren't supported:

  • Yarn Plug'n'Play.
  • pnpm with shared-workspace-lockfile=false.
  • Workspace packages that ship raw TypeScript and are loaded by Node.js at runtime. Node.js doesn't strip types from files in node_modules, so these packages need to be compiled in your build command or bundled by your framework, for example with transpilePackages in Next.js.

Debugging

  • If you updated your site's configuration but the deployment is not working as expected, you may need to first redeploy your site before the changes take effect.
  • If you're missing some code files at build time, verify your build command and ensure that the build output is included in the Git configuration's output directory. Only files in the output directory folder will be available after deployment.
  • If you're self-hosting Appwrite, you will need to configure some environment variables to enable Git deployments.

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.