Skip to content

Instantly share code, notes, and snippets.

@ghelobytes
Last active February 8, 2024 17:38
Show Gist options
  • Save ghelobytes/18af6df89036ecbe1af3647853e86d9e to your computer and use it in GitHub Desktop.
Save ghelobytes/18af6df89036ecbe1af3647853e86d9e to your computer and use it in GitHub Desktop.
Add prompt to confirm correct cluster but doesn't prompt when CI=true (GH actions)
delete-namespace: check-cluster
kubectl delete namespace sandbox
check-cluster:
@if [ -z "$(CI)" ]; then current_context=$(shell kubectl config current-context); \
echo "The current context is `tput bold`$$current_context`tput sgr0`."; \
read -p "Is this the correct context? (y/n): " answer; if [ "$$answer" != "y" ]; \
then echo "Aborted."; exit 1; fi; echo "Proceeding..."; \
fi
# $ make delete-namespace
# The current context is docker-desktop.
# Is this the correct context? (y/n): y
# Proceeding...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment