Skip to content

Commit 2ec266f

Browse files
committed
fix(ci): resolve critical race condition in deploy job artifacts
The deploy job was downloading build artifacts to path: ., then running pnpm install which overwrote the downloaded dist directory. This caused both smoke-tests and deploy jobs to fail with "Directory does not exist" errors when trying to access ./dist/apps/web. Fixed by: 1. Download artifacts to temporary directory (build-artifacts-temp) 2. Install dependencies first 3. Move dist directory from temp to expected location 4. Verify structure and clean up temp directory This resolves the race condition where pnpm install was overwriting downloaded build artifacts, preventing successful deployment.
1 parent c975351 commit 2ec266f

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -907,46 +907,47 @@ jobs:
907907
- name: Setup Pages
908908
uses: actions/configure-pages@v5
909909

910-
- name: Install dependencies
911-
timeout-minutes: 5
912-
run: pnpm install --frozen-lockfile
913-
914-
- name: Download build artifacts
910+
- name: Download build artifacts to temp directory
915911
uses: actions/download-artifact@v6
916912
with:
917913
name: build-artifacts
918-
path: .
914+
path: build-artifacts-temp
919915

920-
- name: Install PostHog CLI
921-
run: npm install -g @posthog/cli
916+
- name: Install dependencies
917+
timeout-minutes: 5
918+
run: pnpm install --frozen-lockfile
922919

923-
- name: Verify artifact structure
920+
- name: Restore build artifacts
924921
run: |
925-
echo "=== Current directory structure ==="
926-
find . -maxdepth 1 -type f -o -type d | head -20
927-
echo "=== Checking for dist directory ==="
928-
if [ -d "dist" ]; then
929-
echo "✅ dist directory found"
930-
find dist -maxdepth 2 -type f -o -type d | head -20
931-
if [ -d "dist/apps" ]; then
932-
echo "✅ dist/apps directory found"
933-
find dist/apps -maxdepth 1 -type d
934-
if [ -d "dist/apps/web" ]; then
935-
echo "✅ dist/apps/web directory found"
936-
find dist/apps/web -maxdepth 1 -type f | head -10
937-
else
938-
echo "❌ dist/apps/web directory NOT found"
939-
exit 1
940-
fi
941-
else
942-
echo "❌ dist/apps directory NOT found"
943-
exit 1
944-
fi
922+
echo "=== Restoring build artifacts from temp directory ==="
923+
if [ -d "build-artifacts-temp/dist" ]; then
924+
echo "✅ Found dist directory in temp artifacts"
925+
mv build-artifacts-temp/dist ./dist
926+
echo "✅ Moved dist directory to expected location"
945927
else
946-
echo "❌ dist directory NOT found"
928+
echo "❌ dist directory not found in temp artifacts"
929+
echo "=== Contents of temp directory ==="
930+
find build-artifacts-temp -type f -o -type d | head -20
947931
exit 1
948932
fi
949933
934+
# Verify the restored structure
935+
if [ -d "dist/apps/web" ]; then
936+
echo "✅ dist/apps/web directory restored successfully"
937+
find dist/apps/web -maxdepth 1 -type f | head -5
938+
else
939+
echo "❌ dist/apps/web directory not found after restore"
940+
exit 1
941+
fi
942+
943+
# Clean up temp directory
944+
rm -rf build-artifacts-temp
945+
echo "✅ Temporary artifacts directory cleaned up"
946+
947+
- name: Install PostHog CLI
948+
run: npm install -g @posthog/cli
949+
950+
950951
- name: Inject source map metadata
951952
run: posthog-cli --host https://eu.posthog.com sourcemap inject --version ${{ github.sha }} --directory ./dist/apps/web
952953
env:

0 commit comments

Comments
 (0)