diff --git a/.github/actions/docker/action.yml b/.github/actions/docker/action.yml index 8e12c3d0..97aa3ace 100644 --- a/.github/actions/docker/action.yml +++ b/.github/actions/docker/action.yml @@ -124,7 +124,7 @@ runs: - name: Build and export to Docker uses: docker/build-push-action@v5 - if: inputs.PLATFORMS == 'linux/amd64' && inputs.TAG_ONLY == 'false' + if: inputs.TAG_ONLY == 'false' with: load: true tags: | @@ -133,7 +133,8 @@ runs: # cache-to: type=gha,mode=max file: ${{ inputs.FILE }} context: ${{ inputs.CONTEXT }} - platforms: ${{ inputs.PLATFORMS }} + # cannot use multiple platforms with `load`, build a single arch image for validation purposes in CI + platforms: linux/amd64 build-args: ${{ env.BUILD_ARGS }} secrets: ${{ env.DOCKER_SECRETS }} @@ -142,14 +143,13 @@ runs: id: test shell: bash run: | - docker run -d --rm --name test ${{ fromJSON(steps.meta.outputs.json).tags[0] }} ${{ inputs.CONTAINER_TEST_COMMAND }} + docker images + echo "Starting container for image: ${{ steps.meta.outputs.tags }}" + docker run -d --rm --name test ${{ fromJSON(steps.meta.outputs.json).tags[0] }} sleep 20 - docker logs test > logs.txt - EXECUTIONLOG=$(cat logs.txt) - EXECUTIONLOG="${EXECUTIONLOG//'%'/'%25'}" - EXECUTIONLOG="${EXECUTIONLOG//$'\n'/'%0A'}" - EXECUTIONLOG="${EXECUTIONLOG//$'\r'/'%0D'}" - echo "name=container-logs::$EXECUTIONLOG" >> $GITHUB_OUTPUT + docker ps + docker logs test + ${{ inputs.CONTAINER_TEST_COMMAND }} - name: Build and push if: inputs.PUSH == 'true' # && inputs.TAG_ONY == 'false' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efdbd583..3f39c89d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,6 +91,10 @@ on: type: boolean default: true description: 'Whenever the container should be tested on pr.' + CONTAINER_TEST_COMMAND: + type: string + default: '' + description: 'A custom command to test the docker container.' RUNNER: type: string default: 'ubuntu-latest' @@ -251,6 +255,7 @@ jobs: PLATFORMS: ${{ inputs.PLATFORMS }} CONTAINER_SCAN: ${{ inputs.CONTAINER_SCAN }} CONTAINER_TEST: ${{ inputs.CONTAINER_TEST }} + CONTAINER_TEST_COMMAND: ${{ inputs.CONTAINER_TEST_COMMAND }} RUNNER: ${{ inputs.RUNNER }} TAG: ${{ inputs.TAG }} BUILD_ARGS: ${{ inputs.BUILD_ARGS }} diff --git a/.gitignore b/.gitignore index 5ae19268..e5e8094f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -./sonarscanner \ No newline at end of file +./sonarscanner +.DS_Store