Skip to content

BE-M0-28 · Link the CLI to staging

ID BE-M0-28 · Level L0 · Pack Pack F · Staging · Run order row 32 · Issue #22

The Supabase CLI in ~/opleet-v2/opleet is linked to opleet-v2-staging, the project TL-M0-20 made, and to nothing else. From here on, --linked means staging. The CLI is never linked to v1's project or to a production project (D5, D11). This step changes no file in the repository: the link lives in the git-ignored supabase/.temp/.

  • Timeline row 31, TL-M0-20, is Done: #21 shows a clean run. So:
    • the project opleet-v2-staging exists, and its ref is in your password manager as <STAGING_PROJECT_REF>;
    • the CLI is logged in (pnpm supabase login);
    • .env.staging holds SUPABASE_URL, SUPABASE_SECRET_KEY and STAGING_PROJECT_REF, with mode 600.
  • The password manager is open on the "Opleet v2 staging" entry. You'll need its database password, <STAGING_DB_PASSWORD>, at a prompt.

1 · Start from main, up to date, with a clean tree

Section titled “1 · Start from main, up to date, with a clean tree”

Every pack F step runs from main, so staging always holds main's migrations (D11).

Terminal window
cd ~/opleet-v2/opleet
git switch main && git pull
git status --short

Type the ref from the password manager in place of <STAGING_PROJECT_REF>. It isn't a secret.

Terminal window
pnpm supabase link --project-ref <STAGING_PROJECT_REF>

If it asks for the database password, paste <STAGING_DB_PASSWORD> from the password manager at the prompt and press Return. Nothing shows as you paste. Never pass it with -p or put it in a file.

  • Block 1: "Already on 'main'" or "Switched to branch 'main'", then "Already up to date." or the pull's summary. git status --short prints nothing.
  • Block 2: "Finished supabase link." It may first say it's connecting to the project or ask for the password.
Terminal window
ref="$(cat supabase/.temp/project-ref)"; want="$(sed -n 's/^STAGING_PROJECT_REF=//p' .env.staging)"; [ -n "$ref" ] && [ "$ref" = "$want" ] && echo "linked to staging" || echo "STOP: not linked to staging"
git check-ignore -v supabase/.temp/project-ref
git status --short
pnpm supabase projects list
  • The first line prints "linked to staging": the linked ref is the one .env.staging names. Later steps run this same test before they touch the linked project.
  • git check-ignore prints a line from supabase/.gitignore ending in supabase/.temp/project-ref.
  • git status prints nothing.
  • projects list shows opleet-v2-staging with a mark in its LINKED column, and no other project marked.
  • Block 1 shows changed files: stop. Don't link from a dirty tree. Paste the output of git status --short.
  • "Invalid project ref format": the ref must be exactly 20 lowercase letters and digits. Copy it again from the dashboard address, after /project/.
  • "Unauthorized", or "Access token not provided": run pnpm supabase login again, then block 2.
  • "password authentication failed": paste the password again from the password manager. If it still fails, reset it in the dashboard (Project Settings › Database), save the new one in the password manager first, then run block 2 again.
  • The check prints "STOP: not linked to staging": run pnpm supabase unlink, then paste both values into #22: cat supabase/.temp/project-ref and grep STAGING_PROJECT_REF .env.staging. Neither is a secret. Don't run BE-M0-29.
  • projects list marks a project that isn't opleet-v2-staging: the same. Unlink, and stop.
Terminal window
pnpm supabase unlink

This removes the link from supabase/.temp/ and changes nothing on staging.

Log each run as a comment on #22: the date, what you ran, and the check's output. Never paste the database password, the secret key or anything from .env.staging except the project ref.