Files
budget-app/apps/appwrite/scripts/deploy.sh
Kushal Gaywala e0e0cc65f1 chore: convert to Turborepo + npm workspaces monorepo
- Move React/Vite frontend to apps/web/ (@budgetwise/web)
- Add apps/appwrite/ (@budgetwise/appwrite) to source-control the
  Appwrite backend: declarative schema in appwrite.json (5 collections),
  CLI-based deploy.sh for containerized use, functions/ dir for future
  Appwrite Functions
- Add turbo.json for task orchestration (build, deploy, dev)
- Replace .gitlab-ci.yml with Woodpecker CI pipelines in .woodpecker/:
    web-production.yml  — push to main → build + rsync to prod
    web-staging.yml     — push to staging → build + rsync to staging
    web-preview.yml     — PR open → deploy to {pr}.{domain}; PR close → cleanup
    appwrite.yml        — schema changes in apps/appwrite/ → CLI deploy
- All secrets injected via Woodpecker CI (no committed .env files)
2026-02-28 19:16:26 +01:00

59 lines
2.8 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# BudgetWise Appwrite Deploy Script
#
# Deploys the schema defined in appwrite.json (databases, collections) using
# the Appwrite CLI. Runs functions deploy if functions/ contains any functions.
#
# Works locally and in CI (Woodpecker, Docker, etc.) — credentials come from
# environment variables, never from committed files.
#
# Required environment variables:
# APPWRITE_ENDPOINT e.g. https://appwrite.example.com/v1
# APPWRITE_PROJECT_ID The Appwrite project ID
# APPWRITE_API_KEY API key with databases.write + collections.write scopes
#
# Local usage:
# export APPWRITE_ENDPOINT=... APPWRITE_PROJECT_ID=... APPWRITE_API_KEY=...
# bash scripts/deploy.sh
#
# Or with a local .env file at apps/appwrite/.env:
# set -a && source .env && set +a && bash scripts/deploy.sh
# ─────────────────────────────────────────────────────────────────────────────
set -euo pipefail
APPWRITE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CLI="npx --yes appwrite@6"
# ── Validate required env vars ────────────────────────────────────────────────
: "${APPWRITE_ENDPOINT:?APPWRITE_ENDPOINT is required}"
: "${APPWRITE_PROJECT_ID:?APPWRITE_PROJECT_ID is required}"
: "${APPWRITE_API_KEY:?APPWRITE_API_KEY is required}"
echo "==> Deploying Appwrite schema"
echo " Endpoint : $APPWRITE_ENDPOINT"
echo " Project : $APPWRITE_PROJECT_ID"
# ── Configure CLI session ─────────────────────────────────────────────────────
# Writes to ~/.appwrite/prefs.json — ephemeral in CI runners.
$CLI client \
--endpoint "$APPWRITE_ENDPOINT" \
--project-id "$APPWRITE_PROJECT_ID" \
--key "$APPWRITE_API_KEY"
# ── Deploy databases + collections ────────────────────────────────────────────
cd "$APPWRITE_DIR"
echo "==> Deploying databases..."
$CLI deploy database --all --yes
# ── Deploy functions (skipped if functions/ is empty) ─────────────────────────
if [ -d "functions" ] && [ -n "$(ls -A functions 2>/dev/null | grep -v '\.gitkeep')" ]; then
echo "==> Deploying functions..."
$CLI deploy function --all --yes
else
echo "==> No functions to deploy, skipping."
fi
echo "==> Appwrite deploy complete."