Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Deploy scripts live in the repository | 1 | #!/usr/bin/env bash |
| 2 | # Deploys g1t: every part, or the ones named, in the order they depend on | |
| 3 | # each other. Each part's D1 migrations are applied before its code goes | |
| 4 | # out, so new code never meets an old database. | |
| 5 | # | |
| 6 | # scripts/deploy.sh # everything | |
| 7 | # scripts/deploy.sh billing web # just these, still in order | |
| 8 | # | |
| 9 | # Uses your `wrangler login`. The repository's .env may hold a token for | |
| 10 | # other tools; it is ignored here unless you set CLOUDFLARE_DEPLOY_TOKEN. | |
| 11 | set -euo pipefail | |
| 12 | ||
| 13 | ROOT="$(cd "$(dirname "$0")/.." && pwd)" | |
| 14 | export CLOUDFLARE_API_TOKEN="${CLOUDFLARE_DEPLOY_TOKEN:-}" | |
| 15 | ||
| 16 | # Dependency order: what others bind to goes first. | |
| 17 | ORDER=( | |
| 18 | services/events | |
| 19 | services/identity | |
| 20 | services/repos | |
| 21 | services/work | |
| Search across all of g1t, Explore, and a command palette | 22 | services/search |
| Projects: what a workspace builds and runs, first on every page | 23 | services/projects |
| Deploy scripts live in the repository | 24 | services/billing |
| 25 | services/integrations | |
| 26 | services/webhooks | |
| 27 | services/actions | |
| 28 | services/models | |
| 29 | services/deployments | |
| 30 | services/runner | |
| 31 | apps/api | |
| 32 | services/pages | |
| Social cards for every page: og.g1t.sh | 33 | services/og |
| Deploy scripts live in the repository | 34 | apps/web |
| Billing accounts, terms and enterprises; g1t is no longer free | 35 | apps/sudo |
| Deploy scripts live in the repository | 36 | apps/docs |
| 37 | ) | |
| 38 | ||
| 39 | wanted() { | |
| 40 | [ $# -eq 0 ] && return 0 | |
| 41 | local dir="$1"; shift | |
| 42 | for name in "${PICK[@]}"; do | |
| 43 | [ "$dir" = "$name" ] || [ "$(basename "$dir")" = "$name" ] && return 0 | |
| 44 | done | |
| 45 | return 1 | |
| 46 | } | |
| 47 | ||
| 48 | PICK=("$@") | |
| 49 | for dir in "${ORDER[@]}"; do | |
| 50 | [ ${#PICK[@]} -eq 0 ] || wanted "$dir" || continue | |
| 51 | echo "== $dir" | |
| 52 | cd "$ROOT/$dir" | |
| 53 | db=$(grep -o '"database_name": *"[^"]*"' wrangler.jsonc 2>/dev/null | head -1 | sed 's/.*"\([^"]*\)"$/\1/' || true) | |
| 54 | if [ -n "$db" ] && [ -d migrations ]; then | |
| 55 | npx wrangler d1 migrations apply "$db" --remote | |
| 56 | fi | |
| 57 | if grep -q '"deploy": "[^"]*build' package.json 2>/dev/null; then | |
| 58 | npm run deploy | |
| 59 | else | |
| 60 | npx wrangler deploy | |
| 61 | fi | |
| 62 | done | |
| 63 | echo "== Deployed." |