From 711dd2d88ff17e6432646a8eed2e4b983cc11e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 5 Feb 2023 21:40:22 +0300 Subject: [PATCH] refactor(action): simplify git safe directory workaround --- entrypoint.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 458f259..d437b01 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,8 +5,9 @@ set -uxo pipefail set -o noglob # Set up working directory -owner=$(stat -c "%u:%g" .) -chown -R "$(id -u)" . +if [[ $(id -u) -ne $(stat -c '%u' .) ]]; then + eids=$(stat -c '--euid %u --egid %g' .) +fi # Create the output directory OUTPUT=${OUTPUT:="git-cliff/CHANGELOG.md"} @@ -16,15 +17,12 @@ mkdir -p "$(dirname $OUTPUT)" args=$(echo "$@" | xargs) # Execute git-cliff -GIT_CLIFF_OUTPUT="$OUTPUT" git-cliff $args +GIT_CLIFF_OUTPUT="$OUTPUT" ${eids:+setpriv --clear-groups $eids} git-cliff $args exit_code=$? # Output to console cat "$OUTPUT" -# Revert permissions -chown -R "$owner" . - # Set the changelog content echo "content<> $GITHUB_OUTPUT cat "$OUTPUT" >> $GITHUB_OUTPUT