diff --git a/README.md b/README.md index 3822024..d56c401 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,10 @@ or - **pull_image_and_stages**: Set to `false` to avoid pulling from the registry or to build from scratch (default: `true`). -- **stages_image_name**: Set custom name for stages/cache image (default: `${image_name}-stages`). Tags are ignored. +- **stages_image_name**: Set custom name for stages/cache image (default: `${image_name}-stages`). + +- **stages_image_tag**: Set custom tag for the stages/cache image. (default: latest)" + required: false - **push_image_and_stages**: Test a command before pushing. Use `false` to not push at all (default: `true`). diff --git a/action.yml b/action.yml index 5636329..ab25299 100644 --- a/action.yml +++ b/action.yml @@ -45,6 +45,9 @@ inputs: stages_image_name: description: "(Optional) Use a custom name for the stages. Useful if using a job matrix (default: ${image_name}-stages)" required: false + stages_image_tag: + description: "(Optional) Use a custom tag for the stages image. (default: latest)" + required: false push_git_tag: description: "(Optional) In addition to `image_tag` value, you can also push current git tag (default: false)" required: false diff --git a/docker-build.sh b/docker-build.sh index 054f57c..368dcdd 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -96,9 +96,13 @@ _get_stages_image_name() { echo "${INPUT_STAGES_IMAGE_NAME:-${INPUT_IMAGE_NAME}-stages}" } +_get_stages_image_tag() { + echo "${INPUT_STAGES_IMAGE_TAG:-latest}" +} + _get_full_stages_image_name() { echo "$(_get_image_namespace)$(_get_stages_image_name)" -} +} _tag() { local tag @@ -167,7 +171,7 @@ _push_image_stages() { local stage_image for stage in $(_get_stages); do echo -e "\nPushing stage: $stage_number" - stage_image=$(_get_full_stages_image_name):$stage_number + stage_image=$(_get_full_stages_image_name):"$(_get_stages_image_tag)"-$stage_number docker tag "$stage" "$stage_image" docker push "$stage_image" stage_number=$(( stage_number+1 )) @@ -175,7 +179,7 @@ _push_image_stages() { # push the image itself as a stage (the last one) echo -e "\nPushing stage: $stage_number" - stage_image=$(_get_full_stages_image_name):$stage_number + stage_image=$(_get_full_stages_image_name):"$(_get_stages_image_tag)"-$stage_number docker tag "$DUMMY_IMAGE_NAME" "$stage_image" docker push "$stage_image" } @@ -396,7 +400,7 @@ _build_image_buildkit() { echo -e "\n[Action Step] Building image with BuildKit..." local cache_image - cache_image="$(_get_full_stages_image_name)":latest + cache_image="$(_get_full_stages_image_name)":"$(_get_stages_image_tag)" local cache_from if _can_pull; then