From 20173de989ec7311b36c6a7f69f74d81dfbddbb5 Mon Sep 17 00:00:00 2001
From: Sandro Modarelli <sandro.modarelli@gmail.com>
Date: Fri, 25 Mar 2022 15:09:12 +0100
Subject: [PATCH] feat: adding debug flag

---
 README.md     | 1 +
 action.yml    | 3 +++
 entrypoint.sh | 3 +++
 3 files changed, 7 insertions(+)

diff --git a/README.md b/README.md
index 76ea61b..6dff48a 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,7 @@ the most used values. So, technically there is a single required argument
 | path                  | Path to the build context. Defaults to `.`                      | false    | .               |
 | tag_with_latest       | Tags the built image with additional latest tag                 | false    |                 |
 | target                | Sets the target stage to build                                  | false    |                 |
+| debug                 | Enables trace for entrypoint.sh                                 | false    |                 |
 
 **Here is where it gets specific, as the optional arguments become required depending on the registry targeted**
 
diff --git a/action.yml b/action.yml
index bc41cfb..cb313e3 100644
--- a/action.yml
+++ b/action.yml
@@ -54,6 +54,9 @@ inputs:
   target:
     description: Sets the target stage to build
     required: false
+  debug:
+    description: Enables trace for entrypoint.sh
+    required: false
 runs:
   using: "docker"
   image: "Dockerfile"
diff --git a/entrypoint.sh b/entrypoint.sh
index d2f4421..bbeeff8 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -1,5 +1,8 @@
 #!/busybox/sh
 set -e pipefail
+if [[ "$INPUT_DEBUG" == "true" ]]; then
+    set -o xtrace
+fi
 
 export REGISTRY=${INPUT_REGISTRY:-"docker.io"}
 export IMAGE=${INPUT_IMAGE}