From fa5b23404620a551c2de927e4dbe650c344b36e0 Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Mon, 6 Jan 2025 19:16:09 +0000 Subject: [PATCH] chore: replace docker-build action with commands --- .github/actions/build-image/action.yml | 46 +++++++++++++++----------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/.github/actions/build-image/action.yml b/.github/actions/build-image/action.yml index dc5df57..9761610 100644 --- a/.github/actions/build-image/action.yml +++ b/.github/actions/build-image/action.yml @@ -68,33 +68,39 @@ runs: digest=$(podman image inspect ${{ inputs.image-name }}:${tag_array[0]} --format "{{.Digest}}") echo "digest=$digest" >> $GITHUB_OUTPUT - - name: Generate Tags (Docker) + - name: Build (Docker) if: ${{ inputs.builder == 'docker' }} - id: generate-image-tags-docker + id: build-docker + # uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6 + # with: + # context: ${{ inputs.context }} + # file: ${{ inputs.dockerfile }} + # tags: ${{ steps.generate-image-tags-docker.outputs.tags }} + # build-args: ${{ inputs.build-args }} + # push: false shell: bash run: | - # Reading space-separated list into an array - IFS=' ' read -r -a tag_array <<< "${{ inputs.image-tags }}" + BUILD_ARG_FLAGS="" + if [ -n "${{ inputs.build-args }}" ]; then + IFS=' ' read -r -a build_args_array <<< "${inputs.build-args}" + for build_arg in "${build_args_array[@]}"; do + BUILD_ARG_FLAGS+="--build-arg $build_arg " + done + fi - # Iterate over all tag inputs and prepend the image name - tags="" + TAGS_FLAGS="" + IFS=' ' read -r -a tag_array <<< "${inputs.image-tags}" for tag in "${tag_array[@]}"; do - tags+="${{ inputs.image-name }}:$tag, " + TAGS_FLAGS+="--tag ${{ inputs.image-name }}:$tag " done - # Remove trailing comma and space - tags="${tags%, }" - echo "tags=$tags" >> $GITHUB_OUTPUT - - name: Build (Docker) - if: ${{ inputs.builder == 'docker' }} - id: build-docker - uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6 - with: - context: ${{ inputs.context }} - file: ${{ inputs.dockerfile }} - tags: ${{ steps.generate-image-tags-docker.outputs.tags }} - build-args: ${{ inputs.build-args }} - push: false + docker build \ + $BUILD_ARG_FLAGS \ + $TAGS_FLAGS \ + ${{ inputs.context }} + + digest=$(docker image inspect ${{ inputs.image-name }}:${tag_array[0]} --format "{{.Id}}") + echo "digest=$digest" >> $GITHUB_OUTPUT - name: Set Outputs id: set-outputs