refactor(action): further simplify git safe directory workaround

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

View File

@@ -4,9 +4,10 @@ set -uxo pipefail
# Avoid file expansion when passing parameters like with '*' # Avoid file expansion when passing parameters like with '*'
set -o noglob set -o noglob
# Set up working directory # Set up permissions
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