From a58f82925ce12027ebcb0810f2c20a9879fae9cf Mon Sep 17 00:00:00 2001 From: George Adams Date: Thu, 10 Oct 2024 12:19:33 +0100 Subject: [PATCH] add test docker image to ghcr for dynamic VM testing --- .github/workflows/build_test_containers.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_test_containers.yml b/.github/workflows/build_test_containers.yml index 8e4154f85a..b160110022 100644 --- a/.github/workflows/build_test_containers.yml +++ b/.github/workflows/build_test_containers.yml @@ -34,17 +34,21 @@ jobs: - name: Get list of changed Dockerfiles id: get_changed_files run: | - changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep ansible/docker/test/Dockerfile) - echo "changed_files=$changed_files" >> "$GITHUB_OUTPUT" + if [ ${{ github.event_name }} == "push" ]; then + changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep ansible/docker/test/Dockerfile) + else + changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep ansible/docker/test/Dockerfile) + fi + echo "changed_files=$changed_files" >> "$GITHUB_ENV" # Generate matrix - name: Generate matrix id: generate_matrix run: | - matrix=$(jq -n --arg files "$changed_files" '{ - include: ($files | split("\n") | map(select(length > 0) | {dockerfile: .})) + matrix=$(jq -n --arg files "${changed_files}" '{ + "include": ($files | split("\n") | map(select(length > 0) | {dockerfile: .})) }') - echo "matrix=$matrix" >> "$GITHUB_OUTPUT" + echo "matrix<> $GITHUB_OUTPUT build-dockerfiles: name: Build Dockerfiles