Skip to content

Commit

Permalink
Fix error when main tag does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
siebsie23 authored Feb 21, 2024
1 parent d04e9f8 commit 6b9d4ee
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions .github/actions/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,23 @@ if [[ "${POSTAL_VERSION}" == "main" ]]; then
SHORT_COMMIT=$(echo "${LATEST_COMMIT}" | cut -c1-7);

# Pull the image from Docker Hub
docker pull siebsie23/docker-postal:main

# Get the image ID
IMAGE_ID=$(docker images -q siebsie23/docker-postal:main)

# Inspect the image and get the commit label
IMAGE_COMMIT=$(docker inspect --format '{{ index .Config.Labels "commit"}}' "${IMAGE_ID}")

# Check if the commit label is the same as the latest commit
if [[ "${IMAGE_COMMIT}" == "${SHORT_COMMIT}" ]]; then
echo "The latest commit ${SHORT_COMMIT} is already built in siebsie23/docker-postal:main";
exit 0;
docker pull siebsie23/docker-postal:main || true

# Check if the image exists locally
if docker image inspect siebsie23/docker-postal:main >/dev/null 2>&1; then
# Get the image ID
IMAGE_ID=$(docker images -q siebsie23/docker-postal:main)

# Inspect the image and get the commit label
IMAGE_COMMIT=$(docker inspect --format '{{ index .Config.Labels "commit"}}' "${IMAGE_ID}")

# Check if the commit label is the same as the latest commit
if [[ "${IMAGE_COMMIT}" == "${SHORT_COMMIT}" ]]; then
echo "The latest commit ${SHORT_COMMIT} is already built in siebsie23/docker-postal:main";
exit 0;
fi
else
echo "Failed to pull siebsie23/docker-postal:main, continuing with build..."
fi
fi

Expand Down

0 comments on commit 6b9d4ee

Please sign in to comment.