From 4a3707d36defbf72009d9a4a8ea7cc56963a365c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 28 Dec 2018 19:17:26 -0500 Subject: [PATCH] feat: tag the "latest" image on tags deploy If the image tag being deployed is not `latest`, we'll retag it as such once the deploy is complete. Closes #3355 --- docs/deployment/methods/images.md | 2 +- plugins/tags/subcommands/deploy | 8 +++++++- tests/unit/40_tags.bats | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/deployment/methods/images.md b/docs/deployment/methods/images.md index 015dd22dd..a153e4977 100644 --- a/docs/deployment/methods/images.md +++ b/docs/deployment/methods/images.md @@ -65,7 +65,7 @@ dokku/node-js-app v1 936a42f25901 About a minute ago ### Deploying an image tag -Finally, you can also deploy a local image using the `tags:deploy` command. +Finally, you can also deploy a local image using the `tags:deploy` command. When specifying a tag that is not `latest`, the released image will be retagged as the `latest` image tag for the app. ```shell dokku tags:deploy node-js-app v1 diff --git a/plugins/tags/subcommands/deploy b/plugins/tags/subcommands/deploy index f924bea67..2b4fd16f0 100755 --- a/plugins/tags/subcommands/deploy +++ b/plugins/tags/subcommands/deploy @@ -12,7 +12,13 @@ tags_deploy_cmd() { IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")" verify_image "$IMAGE" || return 1 - release_and_deploy "$APP" "$IMAGE_TAG" + release_and_deploy "$APP" "$IMAGE_TAG" + + if [[ "$IMAGE_TAG" != "latest" ]]; then + local DOKKU_SCHEDULER="$(get_app_scheduler "$APP")" + local LATEST_IMAGE="$(get_app_image_name "$APP")" + plugn trigger scheduler-tags-create "$DOKKU_SCHEDULER" "$APP" "$IMAGE" "$LATEST_IMAGE" + fi } tags_deploy_cmd "$@" diff --git a/tests/unit/40_tags.bats b/tests/unit/40_tags.bats index 3ad1e65ff..c5c5c89ea 100644 --- a/tests/unit/40_tags.bats +++ b/tests/unit/40_tags.bats @@ -45,6 +45,10 @@ teardown() { echo "output: $output" echo "status: $status" assert_success + run /bin/bash -c "docker images | egrep "dokku/${TEST_APP}"| egrep -q latest" + echo "output: $output" + echo "status: $status" + assert_success } @test "(tags) tags:deploy (missing tag)" {