refactor(action): simplify git safe directory workaround

This commit is contained in:
Orhun Parmaksız
2023-02-05 21:40:22 +03:00
parent e18db403ad
commit 711dd2d88f

View File

@@ -5,8 +5,9 @@ set -uxo pipefail
set -o noglob set -o noglob
# Set up working directory # Set up working directory
owner=$(stat -c "%u:%g" .) if [[ $(id -u) -ne $(stat -c '%u' .) ]]; then
chown -R "$(id -u)" . eids=$(stat -c '--euid %u --egid %g' .)
fi
# Create the output directory # Create the output directory
OUTPUT=${OUTPUT:="git-cliff/CHANGELOG.md"} OUTPUT=${OUTPUT:="git-cliff/CHANGELOG.md"}
@@ -16,15 +17,12 @@ mkdir -p "$(dirname $OUTPUT)"
args=$(echo "$@" | xargs) args=$(echo "$@" | xargs)
# Execute git-cliff # Execute git-cliff
GIT_CLIFF_OUTPUT="$OUTPUT" git-cliff $args GIT_CLIFF_OUTPUT="$OUTPUT" ${eids:+setpriv --clear-groups $eids} git-cliff $args
exit_code=$? exit_code=$?
# Output to console # Output to console
cat "$OUTPUT" cat "$OUTPUT"
# Revert permissions
chown -R "$owner" .
# Set the changelog content # Set the changelog content
echo "content<<EOF" >> $GITHUB_OUTPUT echo "content<<EOF" >> $GITHUB_OUTPUT
cat "$OUTPUT" >> $GITHUB_OUTPUT cat "$OUTPUT" >> $GITHUB_OUTPUT