From d38730ca2eacd61194ab17a47f9054a4fd0f069f Mon Sep 17 00:00:00 2001 From: Marcello Date: Fri, 1 Mar 2024 14:49:00 +0100 Subject: [PATCH] log meaningful message if docker login fails (#4553) (cherry picked from commit 0dbf0c9b5b4fc77fc89af7b46464d7c7263cb6e3) --- localnet/manage.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/localnet/manage.sh b/localnet/manage.sh index 9cb37b7977..4b99b22467 100755 --- a/localnet/manage.sh +++ b/localnet/manage.sh @@ -51,7 +51,18 @@ setup() { echo "🐳 Logging in to our Docker Registry. You'll need to create a Classic PAT with packages:read permissions" echo "https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token" + + set +e + # Attempt Docker login docker login ghcr.io + # Check the exit status of the previous command + if [ $? -ne 0 ]; then + echo "Docker login to ghcr.io failed. Please check your credentials (github PAT) and try again." + exit 1 + fi + # Restore the previous errexit setting + set -eo pipefail + touch localnet/.setup_complete } @@ -63,6 +74,16 @@ get-workflow() { break done if [[ $WORKFLOW =~ build-localnet|recreate ]]; then + set +e + # Attempt Docker login + docker login ghcr.io + # Check the exit status of the previous command + if [ $? -ne 0 ]; then + echo "Docker login to ghcr.io failed. Please check your credentials (github PAT) and try again." + exit 1 + fi + # Restore the previous errexit setting + set -eo pipefail echo "❓ Would you like to run a 1 or 3 node network? (Type 1 or 3)" read -r NODE_COUNT if [[ $NODE_COUNT == "1" ]]; then