Skip to content

Commit

Permalink
chore: replace docker-build action with commands
Browse files Browse the repository at this point in the history
  • Loading branch information
p5 committed Jan 6, 2025
1 parent 51c3e84 commit fa5b234
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions .github/actions/build-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fa5b234

Please sign in to comment.