Fresh clone on every automated task, generic repo setup

Always rm -rf ~/project before cloning to avoid stale state from
previous workspace runs on the same PVC. Made setup steps generic
(detect frontend, playwright, migrations) instead of babble-specific.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel Samson
2026-04-12 14:25:17 +01:00
co-authored by Claude Opus 4.6
parent aa986a470e
commit 869d82998b
+18 -10
View File
@@ -490,27 +490,35 @@ resource "coder_agent" "main" {
fi fi
# --- Clone repository --- # --- Clone repository ---
if [ -n "$REPO_CLONE_URL" ] && [ ! -d ~/project ]; then if [ -n "$REPO_CLONE_URL" ]; then
# Always start fresh for automated tasks to avoid stale state
rm -rf ~/project
git clone "$REPO_CLONE_URL" ~/project git clone "$REPO_CLONE_URL" ~/project
cd ~/project cd ~/project
# Switch to develop branch if it exists # Switch to develop branch if it exists
git fetch origin develop 2>/dev/null && git checkout develop 2>/dev/null || true git fetch origin develop 2>/dev/null && git checkout develop 2>/dev/null || true
# Install backend deps # Install deps if package.json exists
npm ci --legacy-peer-deps if [ -f package.json ]; then
npm ci --legacy-peer-deps || npm ci
fi
# Install frontend deps # Install frontend deps if present
if [ -f frontend/package.json ]; then
cd frontend && npm ci && cd .. cd frontend && npm ci && cd ..
npm run build:frontend 2>/dev/null || true
fi
# Build frontend (required — vitest fails without frontend/dist) # Install Playwright if needed
npm run build:frontend if grep -q "playwright" package.json 2>/dev/null; then
# Install Playwright Chromium
npx playwright install chromium npx playwright install chromium
fi
# Apply local migrations # Apply local migrations if script exists
npm run db:migrate:local if npm run --silent db:migrate:local 2>/dev/null; then
echo "Local migrations applied"
fi
fi fi
# --- Automated task execution --- # --- Automated task execution ---