Skip to content

Commit

Permalink
Do not try to identify if the update was done if there was an error p…
Browse files Browse the repository at this point in the history
…ulling the image
  • Loading branch information
andresmoschini committed Apr 16, 2020
1 parent c607452 commit 57c8f9d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ update_services() {
echo "Trying to update service $name with image $image"
docker pull $image && docker service update "$name" $detach_option $registry_auth --image="$image" > /dev/null

previousImage=$(docker service inspect "$name" -f '{{.PreviousSpec.TaskTemplate.ContainerSpec.Image}}')
currentImage=$(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')
if [ "$previousImage" == "$currentImage" ]; then
echo "No updates to service $name!"
if [ $? != 0 ]; then
echo "Error updating service $name!"
else
echo "Service $name was updated!"
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Service $name updated"
body="Service $name was updated from $previousImage to $currentImage"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\"}" "$apprise_sidecar_url"
previousImage=$(docker service inspect "$name" -f '{{.PreviousSpec.TaskTemplate.ContainerSpec.Image}}')
currentImage=$(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')
if [ "$previousImage" == "$currentImage" ]; then
echo "No updates to service $name!"
else
echo "Service $name was updated!"
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Service $name updated"
body="Service $name was updated from $previousImage to $currentImage"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\"}" "$apprise_sidecar_url"
fi
fi
fi
fi
Expand Down

0 comments on commit 57c8f9d

Please sign in to comment.