Use unique db container and cleanup

This commit is contained in:
estebanthi
2026-01-05 11:56:40 +01:00
parent 133731d493
commit 4170b17ea6

View File

@@ -134,7 +134,10 @@ jobs:
db_type="${{ inputs.db_type }}"
case "$db_type" in
postgres|postgresql)
container_name="ci-postgres"
run_id="${GITHUB_RUN_ID:-local}"
attempt="${GITHUB_RUN_ATTEMPT:-0}"
container_name="ci-postgres-${run_id}-${attempt}"
echo "DB_CONTAINER_NAME=$container_name" >> "$GITHUB_ENV"
docker run -d --name "$container_name" \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
@@ -182,3 +185,10 @@ jobs:
- name: Run tests
if: ${{ inputs.test_command != '' }}
run: ${{ inputs.test_command }}
- name: Cleanup database
if: ${{ always() && inputs.enable_db }}
run: |
if [ -n "${DB_CONTAINER_NAME:-}" ]; then
docker rm -f "$DB_CONTAINER_NAME" >/dev/null 2>&1 || true
fi