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:
co-authored by
Claude Opus 4.6
parent
aa986a470e
commit
869d82998b
@@ -490,27 +490,35 @@ resource "coder_agent" "main" {
|
||||
fi
|
||||
|
||||
# --- 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
|
||||
cd ~/project
|
||||
|
||||
# Switch to develop branch if it exists
|
||||
git fetch origin develop 2>/dev/null && git checkout develop 2>/dev/null || true
|
||||
|
||||
# Install backend deps
|
||||
npm ci --legacy-peer-deps
|
||||
# Install deps if package.json exists
|
||||
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 ..
|
||||
npm run build:frontend 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Build frontend (required — vitest fails without frontend/dist)
|
||||
npm run build:frontend
|
||||
|
||||
# Install Playwright Chromium
|
||||
# Install Playwright if needed
|
||||
if grep -q "playwright" package.json 2>/dev/null; then
|
||||
npx playwright install chromium
|
||||
fi
|
||||
|
||||
# Apply local migrations
|
||||
npm run db:migrate:local
|
||||
# Apply local migrations if script exists
|
||||
if npm run --silent db:migrate:local 2>/dev/null; then
|
||||
echo "Local migrations applied"
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Automated task execution ---
|
||||
|
||||
Reference in New Issue
Block a user