From b83926d45e6b199445693ab0a08b73a8e4c7bb09 Mon Sep 17 00:00:00 2001 From: Benjamin Svobodny Date: Thu, 16 Jun 2022 10:18:47 -0400 Subject: [PATCH] fix: use post-entrypoint script to run cleanup tasks --- Dockerfile | 2 ++ action.yml | 2 ++ cleanup.sh | 8 ++++++++ entrypoint.sh | 4 ---- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100755 cleanup.sh diff --git a/Dockerfile b/Dockerfile index 65a7e68..8f3541f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,6 @@ LABEL version="1.1.0" \ COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh +COPY cleanup.sh /cleanup.sh +RUN chmod +x /cleanup.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index 1d0e4ed..b2baff6 100644 --- a/action.yml +++ b/action.yml @@ -7,6 +7,8 @@ branding: runs: using: docker image: Dockerfile + entrypoint: "/entrypoint.sh" + post-entrypoint: "/cleanup.sh" inputs: args: description: Additional arguments to the sonar-scanner diff --git a/cleanup.sh b/cleanup.sh new file mode 100755 index 0000000..e499d4a --- /dev/null +++ b/cleanup.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +_tmp_file=$(ls "${INPUT_PROJECTBASEDIR}/" | head -1) +PERM=$(stat -c "%u:%g" "${INPUT_PROJECTBASEDIR}/$_tmp_file") + +chown -R $PERM "${INPUT_PROJECTBASEDIR}/" \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index f4c1fed..ab61c98 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,7 +27,3 @@ unset JAVA_HOME sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} ${INPUT_ARGS} -_tmp_file=$(ls "${INPUT_PROJECTBASEDIR}/" | head -1) -PERM=$(stat -c "%u:%g" "${INPUT_PROJECTBASEDIR}/$_tmp_file") - -chown -R $PERM "${INPUT_PROJECTBASEDIR}/"