From 9055a69eabd5435e45e6c77ee1f255e28c7e53c0 Mon Sep 17 00:00:00 2001 From: Tristiisch Date: Wed, 16 Apr 2025 19:37:44 +0200 Subject: [PATCH] feat: trace --- action.yml | 5 ++++- docker-entrypoint.sh | 4 ++++ scripts/docker_compose.sh | 3 +++ scripts/docker_secrets.sh | 3 +++ scripts/docker_swarm.sh | 3 +++ scripts/functions.sh | 7 +++++++ 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c7ced41..da73522 100644 --- a/action.yml +++ b/action.yml @@ -53,8 +53,11 @@ inputs: default: false args: description: 'Command arguments for deployment' + trace: + description: 'Log every execution step for detailed tracing (default: false)' + default: false debug: - description: 'Enable debug mode to include additional debugging messages (default: true)' + description: 'Include additional debugging information in the logs (default: false)' default: false runs: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 686ac0b..f5a7d99 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -6,6 +6,10 @@ export WORKDIR . $WORKDIR/scripts/functions.sh +if is_trace; then + set -x +fi + if [ -z "$INPUT_REMOTE_DOCKER_PORT" ]; then INPUT_REMOTE_DOCKER_PORT=22 fi diff --git a/scripts/docker_compose.sh b/scripts/docker_compose.sh index 481080e..c1e571e 100644 --- a/scripts/docker_compose.sh +++ b/scripts/docker_compose.sh @@ -1,6 +1,9 @@ #!/bin/sh set -eu . $WORKDIR/scripts/functions.sh +if is_trace; then + set -x +fi STACK_FILE=${INPUT_STACK_FILE_PATH} DOCKER_OPTIONS=" --log-level debug" diff --git a/scripts/docker_secrets.sh b/scripts/docker_secrets.sh index 3588fd7..95ff887 100755 --- a/scripts/docker_secrets.sh +++ b/scripts/docker_secrets.sh @@ -1,6 +1,9 @@ #!/bin/sh set -eu . $WORKDIR/scripts/functions.sh +if is_trace; then + set -x +fi get_service_secrets() { service_name=$1 diff --git a/scripts/docker_swarm.sh b/scripts/docker_swarm.sh index f5b81ea..52b82bf 100755 --- a/scripts/docker_swarm.sh +++ b/scripts/docker_swarm.sh @@ -1,6 +1,9 @@ #!/bin/sh set -eu . $WORKDIR/scripts/functions.sh +if is_trace; then + set -x +fi DOCKER_OPTIONS=" --log-level debug" diff --git a/scripts/functions.sh b/scripts/functions.sh index ea136b8..1c48d91 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -129,6 +129,13 @@ copy_ssh(){ scp $verbose_arg -P "$SSH_PORT" "$local_file" "$DOCKER_USER_HOST:$remote_file" 2>&1 } +is_trace() { + if [ -z "${INPUT_TRACE+set}" ] || [ "$INPUT_TRACE" != "true" ]; then + return 1 + fi + return 0 +} + is_debug() { if { [ -z "${INPUT_DEBUG+set}" ] || [ "$INPUT_DEBUG" != "true" ]; } && { [ -z "${RUNNER_DEBUG+set}" ] || [ "$RUNNER_DEBUG" != "1" ]; }; then return 1