diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index b569b48..ee3a19a 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -67,8 +67,10 @@ jobs: ENV_TMPFILE: /tmp/nexus-deploy-env ENV_POSTGRES_PASSWORD: ${{ secrets.ENV_POSTGRES_PASSWORD }} ENV_JWT_KEY: ${{ secrets.ENV_JWT_KEY }} - ENV_OWNER_PASSWORD: ${{ secrets.ENV_OWNER_PASSWORD }} ENV_OPENCLAW_TOKEN: ${{ secrets.ENV_OPENCLAW_TOKEN }} + # OWNER_PASSWORD is read from the host's persistent .env — NOT from a Gitea secret. + # This ensures the password stays consistent across deploys and the DB is the + # single source of truth after initial seed (enforced by SeedAudit guard). steps: # ═══════════════════════════════════════════════════ @@ -127,20 +129,37 @@ jobs: echo "mutated_main=false" >> "$GITEA_OUTPUT" # ═══════════════════════════════════════════════════ - # Step 4: Build .env from secrets (SAFE) + # Step 4: Build .env from secrets + host .env (SAFE) # # Secrets are written to /tmp/nexus-deploy-env — NEVER # to a file inside the workspace that gets rsync'd to # the host. The temp file is deleted immediately after # compose operations complete. + # + # OWNER_PASSWORD is read from the host's persistent .env + # to ensure it stays the single source of truth. Other + # secrets (POSTGRES_PASSWORD, JWT_KEY, OPENCLAW_TOKEN) + # come from Gitea secrets. # ═══════════════════════════════════════════════════ - - name: Prepare .env (secrets → temp file) + - name: Prepare .env (secrets + host .env → temp file) run: | set -euo pipefail + # Read OWNER_PASSWORD from the host's persistent .env + HOST_OWNER_PASSWORD="" + if [ -f "${DEPLOY_PATH}/.env" ]; then + HOST_OWNER_PASSWORD=$(grep '^OWNER_PASSWORD=' "${DEPLOY_PATH}/.env" | cut -d= -f2- || true) + fi + if [ -z "${HOST_OWNER_PASSWORD}" ]; then + echo "❌ OWNER_PASSWORD not found in ${DEPLOY_PATH}/.env" + echo " The host .env is the single source of truth for the owner password." + echo " Ensure OWNER_PASSWORD is set in the deploy-path .env before deploying." + exit 1 + fi + cat > "${ENV_TMPFILE}" <