diff --git a/.github/workflows/test-deploy-server.yml b/.github/workflows/test-deploy-server.yml index add2bac3c7..9619dbd227 100644 --- a/.github/workflows/test-deploy-server.yml +++ b/.github/workflows/test-deploy-server.yml @@ -152,3 +152,18 @@ jobs: name: playwright-server-${{ matrix.apps }} path: /tmp/playwright-artifacts/ if-no-files-found: ignore + + - name: Zip generated inventory for debugging + if: always() + shell: bash + env: + APP_ID: ${{ matrix.apps }} + run: bash scripts/github/inventory/zip_compose_for_upload.sh + + - name: Upload inventory artifact + if: ${{ always() && !env.ACT }} + uses: actions/upload-artifact@v7 + with: + name: inventory-server-${{ matrix.apps }} + path: /tmp/inventory-server-${{ matrix.apps }}.zip + if-no-files-found: ignore diff --git a/.github/workflows/test-deploy-swarm.yml b/.github/workflows/test-deploy-swarm.yml index 0ea956396c..4658c01dd2 100644 --- a/.github/workflows/test-deploy-swarm.yml +++ b/.github/workflows/test-deploy-swarm.yml @@ -156,6 +156,21 @@ jobs: if: failure() run: ${{ env.SCRIPTS }}/16_collect_diagnostics.sh + - name: "Zip generated inventory for debugging" + if: always() + shell: bash + env: + APP_ID: ${{ matrix.apps }} + run: bash scripts/github/inventory/zip_swarm_for_upload.sh + + - name: "Upload inventory artifact" + if: ${{ always() && !env.ACT }} + uses: actions/upload-artifact@v7 + with: + name: inventory-swarm-${{ matrix.apps }} + path: /tmp/inventory-swarm-${{ matrix.apps }}.zip + if-no-files-found: ignore + - name: "Cleanup" if: always() run: ${{ env.SCRIPTS }}/17_cleanup.sh diff --git a/scripts/github/inventory/zip_compose_for_upload.sh b/scripts/github/inventory/zip_compose_for_upload.sh new file mode 100755 index 0000000000..f6d5a54153 --- /dev/null +++ b/scripts/github/inventory/zip_compose_for_upload.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${APP_ID:?APP_ID is required (matrix.apps)}" + +out="/tmp/inventory-server-${APP_ID}.zip" +stage="/tmp/inventory-server-${APP_ID}" +rm -rf "${stage}" +mkdir -p "${stage}" + +mapfile -t containers < <(docker ps --format '{{.Names}}' | grep '^infinito_nexus_' || true) +for c in "${containers[@]}"; do + docker cp "${c}:/root/inventories" "${stage}/${c}-inventories" 2>/dev/null || true +done + +if [[ -d "${stage}" && -n "$(ls -A "${stage}" 2>/dev/null)" ]]; then + (cd /tmp && zip -r "${out}" "inventory-server-${APP_ID}") +else + echo "No inventories captured from compose containers" +fi diff --git a/scripts/github/inventory/zip_swarm_for_upload.sh b/scripts/github/inventory/zip_swarm_for_upload.sh new file mode 100755 index 0000000000..4026cf0c08 --- /dev/null +++ b/scripts/github/inventory/zip_swarm_for_upload.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -euo pipefail + +: "${APP_ID:?APP_ID is required (matrix.apps)}" + +out="/tmp/inventory-swarm-${APP_ID}.zip" +if [[ -d /tmp/inv ]]; then + (cd /tmp && zip -r "${out}" inv) +else + echo "No inventory found at /tmp/inv" +fi