diff --git a/Dockerfile b/Dockerfile index 7234c30..eb22b1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,10 +19,9 @@ ENV LC_ALL="C.UTF-8" WORKDIR /opt -# https://help.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user -USER root - -# Prepare entrypoint +# Prepare entrypoint and cleanup scripts 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 7c1c588..5e915b6 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,8 @@ branding: runs: using: docker image: Dockerfile + entrypoint: "/entrypoint.sh" + post-entrypoint: "/cleanup.sh" inputs: args: description: Additional arguments to the sonarcloud scanner diff --git a/cleanup.sh b/cleanup.sh new file mode 100644 index 0000000..a2606ba --- /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}/" diff --git a/entrypoint.sh b/entrypoint.sh index d6922f4..7bb2d9f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -20,5 +20,7 @@ fi if [[ -z "${SONARCLOUD_URL}" ]]; then SONARCLOUD_URL="https://sonarcloud.io" fi + unset JAVA_HOME + sonar-scanner -Dsonar.projectBaseDir=${INPUT_PROJECTBASEDIR} -Dsonar.host.url=${SONARCLOUD_URL} ${INPUT_ARGS}