Skip to content

Commit

Permalink
FIX: only store diff if there are file changes (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Sep 5, 2024
1 parent bd94528 commit c6bd82e
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ jobs:
if: always()
name: Determine changed files
run: |
some_file_in_root=$(git ls-files --directory | grep -E '^[^/]+$' | head -n1)
diff_files="$some_file_in_root $(git diff --name-only)"
delimiter="$(openssl rand -hex 8)"
echo "diff<<${delimiter}" >> $GITHUB_OUTPUT
for file in $diff_files; do
echo "$file" | tee -a $GITHUB_OUTPUT
done
echo "${delimiter}" >> $GITHUB_OUTPUT
if [[ $(git diff --name-only) ]]; then
some_file_in_root=$(git ls-files --directory | grep -E '^[^/]+$' | head -n1)
diff_files="$some_file_in_root $(git diff --name-only)"
delimiter="$(openssl rand -hex 8)"
echo "diff<<${delimiter}" >> $GITHUB_OUTPUT
for file in $diff_files; do
echo "$file" | tee -a $GITHUB_OUTPUT
done
echo "${delimiter}" >> $GITHUB_OUTPUT
fi
# https://github.com/actions/upload-artifact/issues/174#issuecomment-934330651
shell: bash
- if: always() && steps.diff.outputs.diff != ''
Expand Down Expand Up @@ -119,14 +121,16 @@ jobs:
if: always()
name: Determine changed files
run: |
some_file_in_root=$(git ls-files --directory | grep -E '^[^/]+$' | head -n1)
diff_files="$some_file_in_root $(git diff --name-only)"
delimiter="$(openssl rand -hex 8)"
echo "diff<<${delimiter}" >> $GITHUB_OUTPUT
for file in $diff_files; do
echo "$file" | tee -a $GITHUB_OUTPUT
done
echo "${delimiter}" >> $GITHUB_OUTPUT
if [[ $(git diff --name-only) ]]; then
some_file_in_root=$(git ls-files --directory | grep -E '^[^/]+$' | head -n1)
diff_files="$some_file_in_root $(git diff --name-only)"
delimiter="$(openssl rand -hex 8)"
echo "diff<<${delimiter}" >> $GITHUB_OUTPUT
for file in $diff_files; do
echo "$file" | tee -a $GITHUB_OUTPUT
done
echo "${delimiter}" >> $GITHUB_OUTPUT
fi
# https://github.com/actions/upload-artifact/issues/174#issuecomment-934330651
shell: bash
- if: always() && steps.diff.outputs.diff != ''
Expand Down

0 comments on commit c6bd82e

Please sign in to comment.