Skip to main content

Git and Deploy

With Git and Deploy («Git و Deploy») you connect a GitHub or GitLab repository to the Project, and the repository becomes the source of the whole app: the frontend, the database migrations, the Edge Functions and the settings.

  • Every push to the production branch builds and publishes the Site and applies the migrations, functions and config.toml to the Project.
  • Every other branch and every pull/merge request gets a preview at its own address; production is not touched.
  • Each deploy's status shows next to the commit on GitHub or GitLab, and one click promotes a preview to production.

Open Git و Deploy in the Project's menu. With no repository connected you see the Connect repository («اتصال Repository») button and the suggested repository layout.

Without git too

The same works without git: deploy the Site with Sites and the backend with arianet baas push from the terminal.

Sample project: arianet-baas-starter​

The fastest way to start is arianet-baas-starter: a small but complete Persian "Notes" app (RTL, Vazirmatn font, light and dark) built with Vite and TypeScript, ready to deploy with Git, that shows every part of Arianet BaaS working together:

FeatureIn the sample
Authsign-up and sign-in with email and password, and one-time SMS codes (09… numbers) on plans with SMS
Database and RLSa notes table with owner-only policies in arianet/migrations
Storagethe private note-images bucket in config.toml, per-user folder policies, images shown through signed URLs
Realtimechanges in one tab or device appear in the others at once, still filtered by RLS
Edge Functionsthe note-stats function (text statistics) with verify_jwt and shared code in _shared

To build your own app from it:

  1. On GitHub, open arianet-baas-starter, click Use this template and create your repository (it can be private).
  2. In the panel, open the Project, go to Git و Deploy, click Connect with GitHub («اتصال با GitHub») and pick the new repository (connect steps).
  3. In the Settings step Vite is detected (npm run build, output dist); name the Site and confirm.

The first deploy starts by itself: the migrations, the bucket, the function and the Site are applied, and ARIANET_BAAS_URL and ARIANET_BAAS_ANON_KEY are set during the build. Local development and every file are explained in the sample's README. GitLab copy: gitlab.com/Sajadonline/arianet-baas-starter.

One-click connect with GitHub or GitLab​

Connect repository is a wizard that needs no token:

  1. Git host («میزبان Git»): choose GitHub or GitLab (gitlab.com) ("no token; only approve access"). For GitLab on your own server choose Self-managed GitLab.
  2. Arianet's access («دسترسی آریانت»): before going to GitHub or GitLab, read what Arianet can and can never do (below) and press Continue to GitHub or Continue to GitLab.
  3. Approve access on GitHub or GitLab:
    • GitHub: install Arianet's app on your account or organization, choosing only the repositories you want (Only select repositories), then authorize.
    • GitLab: Authorize the Arianet application.
  4. You come back to the panel. Choose repository («انتخاب Repository»): repositories are listed with their name, whether they are private, default branch and last update; use Search repository… to find one. On GitHub, if a repository is missing, press Configure Arianet's access on GitHub («دسترسی Arianet را در GitHub تنظیم کنید») and add it to the installation.
  5. Settings («تنظیمات»): the panel reads the repository and proposes the settings: app type, package manager, build command, output folder and Site name (from the repository's name). Pick the production branch («Branch اصلی (Production)») and change the build settings if needed.
  6. Connect and deploy («اتصال و Deploy»): the connection is saved, a webhook is registered on the repository and the first deploy starts; the panel takes you to its live log.

The first deploy applies the repository's migrations, config.toml and functions to this Project. Migrations already applied (from the CLI or the console) are not run again.

To connect you need enough rights on the repository: Admin or Maintain on GitHub, Maintainer or higher on GitLab. An account you linked once is used again without the trip to GitHub or GitLab ("connected with GitHub as @…"); press Another account («حساب دیگر») for a different one.

What Arianet can access​

Arianet canArianet can never
Read the code of only the repositories you choose.Change your code or push anything.
Add a webhook so a push starts a deploy.See your other repositories (on GitHub only the ones you choose; on GitLab only the projects you choose and connect are used).
Show the deploy's result next to your commits (commit status).Access your password.
  • The permissions of Arianet's GitHub app on a repository: read contents (Contents: read) and Metadata, and write only Commit statuses and Webhooks. It has no access to your account settings.
  • The tokens obtained from GitHub or GitLab are stored encrypted, never shown or written to a log, and never available to the build (your code).
  • A linked account belongs to the member who linked it; other members of the Arianet account cannot browse or connect repositories with it.

Revoking access​

  • In the panel: the Linked accounts («حساب‌های متصل») card on the Git and Deploy page lists the identities you linked. Disconnect («قطع اتصال») ends Arianet's access to that account's repositories. If the account is still used by a Project, disconnect that Project's repository first.
  • On GitHub: in your account (or organization) settings, Applications → Installed GitHub Apps, Configure Arianet's app (ariaservice) to take repositories away, or Uninstall it; you can also Revoke it under Authorized GitHub Apps.
  • On GitLab: in Preferences → Applications → Authorized applications, press Revoke for Arianet.

Once access is revoked, the connection shows "needs reconnecting" in the panel and deploys fail with git_reauth_required. Press Reconnect to GitHub (or GitLab) to make the same connection active again.

Self-managed GitLab and token connections​

For GitLab on your own server, choose Self-managed GitLab («GitLab سازمانی / شخصی (Self-managed)») in the first step:

  1. Enter your GitLab address with https and without /api/v4 (such as https://gitlab.example.com). The server must be reachable from the internet.
  2. Create a token on your GitLab opens the personal access token page with the name Arianet and the api scope filled in. Press Create, set an expiry date and paste the token in the panel.
  3. Paste the repository path (such as group/subgroup/my-app) or its full address, and enter the production branch.

For GitHub Enterprise, or if you prefer a token, press Connect with a token (advanced) («اتصال با Token (پیشرفته)») in the first step. The token must be for this repository only:

HostTokenPermissions
GitHub / GitHub EnterpriseFine-grained personal access token, with Only select repositories and only this repositoryContents: Read-only, Webhooks: Read and write, Commit statuses: Read and write (Metadata: Read-only is implied)
GitLabProject access token (Settings → Access tokens)Role: Maintainer (registering the webhook needs it), scopes api and read_repository

For GitHub Enterprise enter the server's API address (usually ending in /api/v3). The token is stored encrypted and only its last four characters are shown. Before it expires, save a new one with Change connection («تغییر اتصال»); with an expired token deploys fail with fetch_failed or repository_token_refused. If the repository belongs to an organization, its owner may have to approve the token.

Repository layout​

<app directory>/
package.json # the Site (optional): built with npm run build
arianet/
config.toml # Auth, buckets, Cron and function settings
migrations/0001_init.sql # in name order, in one transaction
functions/hello/index.ts # one directory per function
functions/_shared/ # code shared by every function

Every part is optional: a repository with only arianet/migrations applies only migrations, and one with only a frontend only publishes the Site. The paths can be changed in the connection settings. The backend is read straight from the repository at the exact commit and needs no build (at most 2,000 files and 64 MB a deploy).

Migrations: arianet/migrations​

  • The .sql files right in this directory (not in subdirectories), in name order. Start the names with a number or a timestamp: 0001_init.sql, 20261129093000_orders.sql.
  • All files not applied yet run together in one transaction: all of them or none. Do not put BEGIN or COMMIT in them.
  • The history is the same as arianet baas db push and the console's: a file applied before is not run again.
  • Do not change an applied file. If the text of a file that already ran changes, the deploy is refused with migration_changed; put the change in a new migration file.
  • At most 200 files and 2 MB of SQL.

Functions: arianet/functions​

  • Every subdirectory is an Edge Function, and the directory's name is the function's: arianet/functions/hello/index.ts.
  • Entry file: index.ts (or index.js, index.mjs, index.tsx, index.jsx, main.ts, main.js), or the one named in [functions.<name>] entrypoint.
  • Put shared code in arianet/functions/_shared/ and import it as ../_shared/x.ts; it goes into every function's bundle.
  • A function whose code did not change is not redeployed. Functions the repository does not hold are left as they are (not deleted).

Settings: arianet/config.toml​

[auth]
site_url = "https://shop.example.com"
redirect_urls = ["https://shop.example.com/*"]
email_enabled = true
phone_enabled = false
anonymous_enabled = false
disable_signup = false

[auth.providers.google] # secrets never go in the repository: set them in the panel
enabled = true
client_id = "1234.apps.example"

[storage.buckets.avatars]
public = true
file_size_limit = 5242880
allowed_mime_types = ["image/png", "image/jpeg"]

[cron.cleanup]
schedule = "0 3 * * *"
sql = """
delete from events where at < now() - interval '30 days';
"""

[cron.ping]
schedule = "*/15 * * * *"
enabled = true
http = { url = "https://shop.example.com/api/ping", method = "POST" }

[functions.hello]
verify_jwt = false
entrypoint = "index.ts"
SectionKeys
[auth]site_url, redirect_urls, email_enabled, phone_enabled, anonymous_enabled, disable_signup (Auth)
[auth.providers.<name>]enabled, client_id (Providers)
[storage.buckets.<name>]public, file_size_limit (bytes), allowed_mime_types (Storage)
[cron.<name>]schedule, enabled, and sql = "…" or http = {url, method, headers, body, timeout_ms} (Cron)
[functions.<name>]verify_jwt, entrypoint (verify_jwt)
  • Every deploy compares the named values with the Project and applies only the differences; the deploy's page lists the changes (create, update, unchanged).
  • Anything the file does not name is not changed or deleted. A bucket, Cron job or provider taken out of the file stays in the Project; delete it in the panel.
  • An unknown key is refused with its line number (invalid_config). Never write secrets (such as a provider's secret) in the file; set them in the panel or with the CLI.

The Site: package.json​

When the connection has a Site, the frontend is built in the app directory and published to the Site:

  • Install: the package manager comes from the lock file (pnpm-lock.yaml → pnpm, yarn.lock → yarn, else npm; with a lock file, npm ci).
  • Build: <package manager> run build when package.json has a build script.
  • Output: the first existing folder of dist, build, out and public, or the one you set.
  • A repository with no package.json but with index.html or public/ is published as a static Site without a build.
  • App types detected automatically: Next.js (static export, out), Nuxt (generate, .output/public), Astro, Vite, Create React App and plain HTML. Server-side rendering (SSR) is not supported yet; build a static output.

Production and the production branch​

The production branch is the branch whose pushes update production; leave it empty for the repository's default branch. A production deploy runs these steps in order, and the first step that fails ends the deploy, with the Project keeping what it had:

StepWhat it does
Reading the repositoryconfig.toml, migrations and functions are read at the commit.
CheckEvery function's bundle is built, the migrations are compared with the history (nothing runs) and the settings' differences are computed.
BuildThe frontend is built and uploaded, but not published yet.
MigrationsThe new migrations run in one transaction.
Settings (config.toml)The differences are applied.
FunctionsChanged functions are deployed. If this step or the next fails, the functions this deploy changed go back to their previous version.
Publishing the SiteThe new Site version is published last, in one switch.
  • A commit that is queued, running or deployed on its branch already is not queued again. A newer commit of a branch supersedes the older queued deploys.
  • With an app directory (root directory) set, a push that changes nothing under it deploys nothing (handy in a monorepo).
  • A Project paused for idleness wakes up for a deploy. A Project you paused yourself takes no deploys (project_not_active).
  • Deploy now («Deploy الان») deploys a branch's latest commit without a new push: the production branch as production, any other branch as a preview.

Previews​

Every push to another branch, and every pull request (GitHub) or merge request (GitLab) opened, reopened or updated, gets a preview:

  • Address: https://<branch>--<site>.site.arianet.app; for example branch feature/checkout of Site shop is https://feature-checkout--shop.site.arianet.app. The branch name is lowercased and every other character becomes a -; very long branches are shortened and end in a short hash.
  • A preview is only built and checked: migrations, settings and functions are not applied to the Project, and production does not change. A preview talks to the same backend (Database and Auth) of the Project, so it works on real data.
  • Previews are served with the Site's rules (SPA fallback, headers, redirects) and X-Robots-Tag: noindex (kept out of search engines), and are automatically allowed Auth redirect targets.
  • Deleting the branch or closing (or merging) the request removes its preview. The Previews card lists every preview with its address and last update, and Delete removes one by hand; the next push to that branch builds it again.
  • The number of previews per Site has a Plan limit; at the limit, the least recently updated preview goes first.
  • Pull requests from forks (other people's repositories) are never built; unknown code never runs on your Project.
  • Previews can be turned off in the connection settings.

Promote, redeploy and cancel​

In the Deploys list (filtered by kind, state and branch) and on each deploy's page:

  • Promote to production: makes a production deploy from a ready preview's commit and reuses its build (no new build). That commit's migrations, config.toml and functions are applied to the Project and the main Site is published with that version.
  • Redeploy: a new deploy of the same commit; the build runs again and uses build minutes.
  • Cancel: a queued deploy is canceled at once, a running one stops at its next step and its build is removed. The Project keeps what it had before the deploy; nothing is left half done.

To roll back only the frontend, use Roll back to the previous version on the Site's page. Migrations do not roll back; write a new migration to undo a database change.

The deploy page and log​

Details and log («جزئیات و Log») of a deploy shows:

  • The commit (message, author and a link to it), branch, source (push, pull/merge request, manual, redeploy or promote), creation time, duration and build time.
  • State: queued, building, deploying, ready, failed, canceled or superseded; while running, the current step.
  • Steps: what was read (number of migrations and functions, whether there is a config.toml), the migrations that ran, the settings changed and the functions deployed.
  • The live log of install and build; tokens are replaced with [redacted].
  • For a failed deploy, the reason in Persian with the service's error text below it (errors).

The 200 newest deploys of a Project are kept.

Commit status​

Every deploy sets a status named arianet/baas on its commit: pending when it starts and success or failure when it ends, linked to the deploy's page in the panel. Pull/merge requests show the same status, so you can require it before merging on GitHub or GitLab.

Build settings and variables​

Connection settings («تنظیمات اتصال», or Change connection for a token connection) holds:

SettingNotes
Production branchEmpty: the repository's default branch
App directory (root directory)In a monorepo, this app's folder; every other path is relative to it. Empty: the repository's root
PreviewsOn or off
Build the frontend and publish it to a SiteOff: only the backend (migrations, functions and config.toml) is applied
Site nameThe Site the build is published to; created with SPA fallback on when missing
Package managerAutomatic (from the lock file), npm, pnpm or yarn
Install command / Build command / Output folderEmpty: detected automatically
Build environment variablesName and value, such as VITE_API_URL
Backend paths in the repositoryMigrations (arianet/migrations), functions (arianet/functions), the config file (arianet/config.toml)
  • Build environment: Node.js 22 with npm, pnpm 9 and yarn 1. Each build runs isolated, with no access to the repository token or the Project's keys.
  • Build variables are not secret and are shown in the console; never put passwords, the Service Key or server keys there. Whatever the build sees is published in the frontend code.
  • ARIANET_BAAS_URL and ARIANET_BAAS_ANON_KEY (this Project's endpoint and anon key) and CI=1 are set automatically. A framework that only passes prefixed variables to browser code (such as VITE_ or NEXT_PUBLIC_) does not see these two; add build variables such as VITE_BAAS_URL and VITE_BAAS_ANON_KEY with the values from API Keys and Connect (the anon key is made for browser code).
  • Setting changes apply from the next deploy.

Build limits​

The Builds this month («Build در این ماه») card shows the minutes used and the Plan's limits. Build time counts from the start to the end of each build.

ItemFree Plan
Build minutes a month100
Concurrent builds per Project1
Time limit of one build15 minutes
Build resources1 vCPU, 2 GB RAM
Previews per Site5
  • On the Free Plan, once the month's minutes are used up, builds do not run until the next month (build_minutes_exhausted). Deploys without a Site (backend only) use no build minutes.
  • Paid Plans have higher limits, and minutes beyond the Plan are billed as usage.

Disconnect the repository​

Disconnect («جدا کردن», type the repository path to confirm): the webhook is removed from the repository, queued deploys are canceled, every preview is removed and later pushes no longer deploy. The published Site, the Database, the functions and the deploy history stay, and you can connect again later. If the webhook cannot be removed, the panel tells you to delete it in the repository's settings yourself.

Change repository (one-click) or changing the host and repository (token connection) removes the old webhook and registers one on the new repository.

Permissions​

  • Seeing the Git and Deploy page needs baas:view; connecting, changing, disconnecting, deploy, redeploy, cancel, promote and deleting previews need baas:git:manage (Members).
  • Each deploy runs with the permissions of the member who last saved the connection, and only those a deploy needs (Site, functions, Auth settings, SQL and Cron, buckets). The Git page lists them. If that member lacks one a step needs, the step fails with forbidden: git never gives anyone more than they had. Save the connection again as a member with enough rights.
  • Every connect, change, deploy, promote and disconnect is recorded in the account's activity log (never a token).

From the terminal​

arianet baas git connect --provider github --repo acme/shop --token-file token.txt --site shop
arianet baas git status # repository, webhook and this month's build minutes
arianet baas git deployments
arianet baas git deploy --branch feature/checkout --follow
arianet baas git logs <deployment-id> --follow
arianet baas git promote <deployment-id>
arianet baas git redeploy <deployment-id>
arianet baas git cancel <deployment-id>
arianet baas git previews # and previews rm <alias>
arianet baas git update --production-branch main --build-command "pnpm build"
arianet baas git disconnect

One-click connect is done in the panel only; git connect in the CLI uses a token. Every flag: the arianet baas git reference.

arianet baas push: the same deploy without git​

arianet baas push --dry-run     # what would change
arianet baas push
arianet baas push 12 --dir apps/shop --skip-functions

Applies a directory's backend in the order a git deploy does: the migrations not applied yet (in one transaction), the differences of config.toml, and the functions. Everything is checked before anything changes. The Site is not part of push; publish it with arianet baas sites deploy. Unlike a git deploy, a failure part way does not undo the steps before it (migrations are still one transaction). The arianet baas push reference

Errors​

Errors of a deploy​

CodeMeaning and fix
invalid_repositoryThe repository's layout is not valid: over 2,000 files or 64 MB in the backend paths, or wrong paths.
invalid_configconfig.toml has an error (unknown key or bad value); the line number is in the error text.
invalid_functionA function's bundle could not be built; check the entry file and the imports.
migration_changedThe text of a migration that already ran has changed; restore the file and put the change in a new one.
migration_failedRunning the migrations failed and none was applied; the SQL error is in the log.
forbiddenThe member who saved the connection lacks this step's permission; save the connection again with enough rights.
project_not_activeThe Project was paused by its owner; resume it in Settings first.
build_failedInstall or build failed; see the log. Try npm ci && npm run build on your own machine once.
build_timeoutThe build ran past the Plan's time limit.
build_out_of_memoryThe build ran out of memory; make it lighter or take a bigger Plan.
build_minutes_exhaustedThis month's build minutes are used up; wait for next month or upgrade the Plan.
builds_unavailableBuilds do not run in this Region yet; a connection without a Site (backend only) works.
fetch_failedFetching the code from the repository failed; check the token and its access.
git_reauth_requiredArianet's access on GitHub or GitLab expired or was revoked; reconnect.
upload_failed / build_lostUploading the build output failed or the build was lost midway; deploy again.
bucket_refusedOne of the buckets in config.toml was refused (for example, over the Plan's limit).
storage_unavailableStorage did not answer; deploy again shortly.
disconnected / canceledThe repository was disconnected midway / the deploy was canceled.
deployment_failedAnother failure; see the log.

In every case the Project keeps what it had before the deploy.

Errors when connecting​

CodeMeaning and fix
repository_permissionYou need the Admin or Maintain role (GitHub) or Maintainer (GitLab) on the repository, and on GitHub Arianet's app must be installed on it.
repository_unreachableThe repository was not found; check its path and the token's access to it.
repository_token_refusedThe token is wrong, expired or revoked.
repository_token_permissionThe token lacks permissions; give it the ones needed.
branch_not_found / path_not_foundThe branch or the app directory is not in the repository.
git_host_unavailableThe git host does not answer; try again shortly.
git_host_not_allowedConnecting to this git host is not allowed (for example, the server is not reachable from the internet).
git_connectedA repository is already connected to this Project; use "Change repository".
oauth_state_invalid / oauth_denied / oauth_exchange_failedThe connection expired, access was not approved on GitHub or GitLab, or the approval did not complete; start again.
git_account_in_useThis linked account is still used by a Project; disconnect that Project's repository first.
git_oauth_unavailableOne-click connect is not on in this Region; connect with a token.
deployment_running / deployment_finished / not_a_previewA deploy of this commit is running; a finished deploy cannot be canceled; only a ready preview can be promoted.
  • Webhook not registered: if the Git page says "Webhook not registered", pushes do not deploy by themselves. Check the token's webhook permission and save the connection again; until then Deploy now works.
  • The return page says "this connection has expired": the browser does not remember the connection (another tab, or after closing the browser). Start the connection again from the Git and Deploy page. In a private browser window where temporary storage is blocked, one-click connect does not work.

Not supported yet​

One-click connect for GitHub Enterprise and self-managed GitLab (connect with a token); a cache between builds; build environments other than Node.js; several Sites in one connection; reviewing and approving config.toml changes before they apply; automatically deleting a function, bucket or Cron job taken out of the repository; server-side rendering (SSR).