From d3e272c587198684dcdd13f328b4a84d396c8a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Mon, 14 Oct 2024 18:12:39 +0300 Subject: [PATCH] fix(action): limit content size to 40MB (#40) * fix(action): limit content size to 50MB * fix(limit): don't echo output on big file --- run.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/run.sh b/run.sh index 8309f47..012a088 100755 --- a/run.sh +++ b/run.sh @@ -24,16 +24,18 @@ exit_code=$? CONTEXT="$(mktemp)" GIT_CLIFF_OUTPUT="$CONTEXT" ./bin/git-cliff $args --context -# Output to console -cat "$OUTPUT" - # Revert permissions chown -R "$owner" . -# Set the changelog content -echo "content<>$GITHUB_OUTPUT -cat "$OUTPUT" >>$GITHUB_OUTPUT -echo "EOF" >>$GITHUB_OUTPUT +# Set the changelog content (max: 50MB) +FILESIZE=$(stat -c%s "$OUTPUT") +MAXSIZE=$((40 * 1024 * 1024)) +if [ "$FILESIZE" -le "$MAXSIZE" ]; then + echo "content<>$GITHUB_OUTPUT + cat "$OUTPUT" >>$GITHUB_OUTPUT + echo "EOF" >>$GITHUB_OUTPUT + cat "$OUTPUT" +fi # Set output file echo "changelog=$OUTPUT" >>$GITHUB_OUTPUT @@ -42,4 +44,4 @@ echo "changelog=$OUTPUT" >>$GITHUB_OUTPUT echo "version=$(jq -r '.[0].version' $CONTEXT)" >>$GITHUB_OUTPUT # Pass exit code to the next step -echo "exit_code=$exit_code" >>$GITHUB_OUTPUT \ No newline at end of file +echo "exit_code=$exit_code" >>$GITHUB_OUTPUT