@@ -213,6 +213,7 @@ jobs:
213213 docker cp e2e-test-durations.json cypress:/e2e/cypress/e2e-test-durations.json
214214
215215 - name : Run the tests
216+ id : run_tests
216217 shell : bash
217218 run : |
218219 docker exec \
@@ -280,6 +281,45 @@ jobs:
280281 name : cypress-docker-reports-${{ strategy.job-index }}
281282 path : ${{ github.workspace }}/test-reports
282283
284+ - name : Collect Docker container logs
285+ id : collect_docker_logs
286+ if : always()
287+ shell : bash
288+ run : |
289+ mkdir -p ${{ github.workspace }}/docker-logs
290+
291+ test_server_logs_exist=false
292+
293+ while IFS= read -r container_name
294+ do
295+ # The Cypress container logs are already available via test report artifacts.
296+ if [[ "${container_name}" == "cypress" ]]
297+ then
298+ continue
299+ fi
300+
301+ docker logs "${container_name}" > "${{ github.workspace }}/docker-logs/${container_name}.log" 2>&1 || true
302+
303+ if [[ -s "${{ github.workspace }}/docker-logs/${container_name}.log" ]]
304+ then
305+ test_server_logs_exist=true
306+ fi
307+ done < <(docker ps --format '{{.Names}}')
308+
309+ if [[ "${test_server_logs_exist}" == "true" ]]
310+ then
311+ find ${{ github.workspace }}/docker-logs -type f
312+ fi
313+
314+ echo "test_server_logs_exist=${test_server_logs_exist}" >> $GITHUB_OUTPUT
315+
316+ - name : Upload Docker server logs as an artifact
317+ if : always() && steps.collect_docker_logs.outputs.test_server_logs_exist == 'true'
318+ uses : actions/upload-artifact@v6
319+ with :
320+ name : cypress-server-logs-${{ strategy.job-index }}
321+ path : ${{ github.workspace }}/docker-logs
322+
283323 publish_e2e_test_results :
284324 name : Publish E2E Test Results
285325 runs-on : ubuntu-24.04
0 commit comments