Skip to content

Commit

Permalink
Merge pull request #148 from whoan/use-images-yq
Browse files Browse the repository at this point in the history
Use image's yq
  • Loading branch information
whoan authored Oct 28, 2023
2 parents 16e9d90 + fac15f5 commit f9327cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ LABEL "repository"="https://github.com/whoan/docker-build-with-cache-action"
COPY docker-build.sh /docker-build.sh
COPY entrypoint.sh /entrypoint.sh

RUN apk add --no-cache bash grep jq
RUN apk add --no-cache bash grep jq yq

ENTRYPOINT ["/entrypoint.sh"]
26 changes: 5 additions & 21 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ if [ -z "$INPUT_COMPOSE_FILE" ]; then
exit
fi

# use image's yq now that it is available
_yq() {
yq "$@"
}

merged_compose=/tmp/merged-compose.yml
original_INPUT_IMAGE_TAG=$INPUT_IMAGE_TAG
original_INPUT_CONTEXT=$INPUT_CONTEXT
Expand All @@ -34,27 +39,6 @@ build_from_compose_file() {
done
}

_yq() {
local yq
yq=$(which yq || true)
if [ -z "$yq" ]; then
yq=/usr/bin/yq
_copy_yq_from_docker_image "$yq" > /dev/null
fi
"$yq" "$@"
}

_copy_yq_from_docker_image() {
local yq_path=$1
: "${yq_path:?I need a path where yq will be copied}"
local hash
yq=/usr/bin/yq
docker pull mikefarah/yq:4.28.2 >&2
hash=$(docker create mikefarah/yq:4.28.2)
docker cp "$hash":/usr/bin/yq "$yq_path"
docker rm "$hash"
}

_merge_yamls() (
local yamls=()
mapfile -d ">" -t yamls < <(echo -n "$INPUT_COMPOSE_FILE")
Expand Down

0 comments on commit f9327cd

Please sign in to comment.