@@ -108,9 +108,20 @@ jobs:
108108 IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
109109 echo "Using image tag: $IMAGE_TAG"
110110
111- # Pull the image locally if it's not available
112- echo "Pulling image to ensure it's available locally..."
113- docker pull "$IMAGE_TAG"
111+ # Check if image is available locally first
112+ if docker images --format "table {{.Repository}}:{{.Tag}}" | grep -q "$IMAGE_TAG"; then
113+ echo "Image found locally, using local image"
114+ else
115+ echo "Image not found locally, attempting to pull..."
116+ if docker pull "$IMAGE_TAG"; then
117+ echo "Successfully pulled image"
118+ else
119+ echo "Failed to pull image, but this might be expected immediately after push"
120+ echo "Waiting 10 seconds and trying again..."
121+ sleep 10
122+ docker pull "$IMAGE_TAG" || echo "Still failed to pull, continuing with local build"
123+ fi
124+ fi
114125
115126 # Save the image as tar
116127 docker save "$IMAGE_TAG" -o wrongsecrets-preview.tar
@@ -195,15 +206,15 @@ jobs:
195206
196207 let filesList = '';
197208 if (relevantFiles.length > 0) {
198- filesList = relevantFiles.slice(0, 10).map(file => `- \`${file.filename}\``).join('\\ n ');
209+ filesList = relevantFiles.slice(0, 10).map(file => `- \`${file.filename}\``).join('\n ');
199210 if (relevantFiles.length > 10) {
200- filesList += `\\ n - ... and ${relevantFiles.length - 10} more files`;
211+ filesList += `\n - ... and ${relevantFiles.length - 10} more files`;
201212 }
202213 } else {
203214 filesList = '- No relevant files changed';
204215 }
205216
206- const finalComment = comment + '\\ n ' + filesList + `
217+ const finalComment = comment + '\n ' + filesList + `
207218
208219 Visual diff screenshots will be available shortly...
209220
@@ -320,48 +331,64 @@ jobs:
320331 sleep 2
321332 done
322333
334+ - name : Setup Node.js
335+ uses : actions/setup-node@v4
336+ with :
337+ node-version : ' 18'
338+
323339 - name : Install Playwright
324340 run : |
325- npm install -g playwright@latest
326- playwright install chromium
341+ npm install playwright@latest
342+ npx playwright install --with-deps chromium
327343
328344 - name : Take screenshots
329345 run : |
330346 mkdir -p screenshots
331347
348+ # Verify services are still running
349+ echo "Verifying services are still running..."
350+ docker ps --filter "name=pr-version" --format "table {{.Names}}\t{{.Status}}"
351+ docker ps --filter "name=main-version" --format "table {{.Names}}\t{{.Status}}"
352+
353+ # Test connectivity one more time
354+ echo "Testing connectivity..."
355+ curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 || echo "PR version not responding"
356+ curl -s -o /dev/null -w "%{http_code}" http://localhost:8081 || echo "Main version not responding"
357+
332358 node -e "
333359 const { chromium } = require('playwright');
334360 (async () => {
335- const browser = await chromium.launch();
361+ const browser = await chromium.launch({ headless: true } );
336362 const page = await browser.newPage();
337363 await page.setViewportSize({ width: 1280, height: 1024 });
338364
339365 try {
340366 // PR version screenshots
341367 console.log('Taking PR screenshots...');
342- await page.goto('http://localhost:8080', { waitUntil: 'networkidle' });
368+ await page.goto('http://localhost:8080', { waitUntil: 'networkidle', timeout: 30000 });
343369 await page.screenshot({ path: 'screenshots/pr-home.png', fullPage: true });
344370
345- await page.goto('http://localhost:8080/about', { waitUntil: 'networkidle' });
371+ await page.goto('http://localhost:8080/about', { waitUntil: 'networkidle', timeout: 30000 });
346372 await page.screenshot({ path: 'screenshots/pr-about.png', fullPage: true });
347373
348374 // Try to get a challenge page
349- await page.goto('http://localhost:8080/challenge/1', { waitUntil: 'networkidle' });
375+ await page.goto('http://localhost:8080/challenge/1', { waitUntil: 'networkidle', timeout: 30000 });
350376 await page.screenshot({ path: 'screenshots/pr-challenge.png', fullPage: true });
351377
352378 // Main version screenshots
353379 console.log('Taking main branch screenshots...');
354- await page.goto('http://localhost:8081', { waitUntil: 'networkidle' });
380+ await page.goto('http://localhost:8081', { waitUntil: 'networkidle', timeout: 30000 });
355381 await page.screenshot({ path: 'screenshots/main-home.png', fullPage: true });
356382
357- await page.goto('http://localhost:8081/about', { waitUntil: 'networkidle' });
383+ await page.goto('http://localhost:8081/about', { waitUntil: 'networkidle', timeout: 30000 });
358384 await page.screenshot({ path: 'screenshots/main-about.png', fullPage: true });
359385
360- await page.goto('http://localhost:8081/challenge/1', { waitUntil: 'networkidle' });
386+ await page.goto('http://localhost:8081/challenge/1', { waitUntil: 'networkidle', timeout: 30000 });
361387 await page.screenshot({ path: 'screenshots/main-challenge.png', fullPage: true });
362388
363389 } catch (error) {
364390 console.error('Screenshot error:', error);
391+ process.exit(1);
365392 } finally {
366393 await browser.close();
367394 }
0 commit comments