🌱 Use git diff instead of external action for changed files (#3894)

* Use git diff instead of third party action.

Signed-off-by: Spencer Schrock <sschrock@google.com>

* clarify approach

Signed-off-by: Spencer Schrock <sschrock@google.com>

---------

Signed-off-by: Spencer Schrock <sschrock@google.com>
This commit is contained in:
Spencer Schrock 2024-02-22 10:07:06 -08:00 committed by GitHub
parent 54690b41ae
commit 4f4b44d08a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,15 +38,17 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
fetch-depth: 2 # needed to diff changed files
- id: files
name: Get changed files
uses: tj-actions/changed-files@90a06d6ba9543371ab4df8eeca0be07ca6054959 #v42.0.2
with:
files_ignore: '**.md'
- id: docs_only_check
if: steps.files.outputs.any_changed != 'true'
name: Check for docs-only changes
run: echo "docs_only=true" >> $GITHUB_OUTPUT
run: |
set +e # dont fail based on grep exit code
git diff --name-only HEAD~1 | grep --ignore-case --invert-match '.md$'
if [ $? -eq 1 ]; then
# no grep match (all files end in .md) produces exit code 1
echo "docs_only=true" >> $GITHUB_OUTPUT
else
echo "docs_only=false" >> $GITHUB_OUTPUT
fi
docker_matrix:
strategy: