Skip to content

Commit

Permalink
Merge pull request #32 from tj-actions/add-support-for-detecting-unst…
Browse files Browse the repository at this point in the history
…aged-files
  • Loading branch information
jackton1 authored Apr 4, 2021
2 parents e3a362a + 70c9d4c commit 97ba4cc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,21 @@ jobs:
run: |
echo "No Changes found: (Not expected)"
exit 1
- name: Generate and unstaged file
run: |
echo "New changes" > unstaged.txt
- name: Test unstaged file has changes
uses: ./
id: changed_unstaged_files_expected
with:
files: |
unstaged.txt
- name: Display unstaged changed files
if: steps.changed_unstaged_files_expected.outputs.files_changed == 'true'
run: |
echo "Changed files: ${{ steps.changed_unstaged_files_expected.outputs.changed_files }}"
- name: Verify Changes to unstaged.txt
if: steps.changed_unstaged_files_expected.outputs.files_changed != 'true'
run: |
echo "No Changes found: (Not expected)"
exit 1
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ for path in ${INPUT_FILES}
do
echo "Checking for file changes: \"${path}\"..."
MODIFIED_FILE=$(git diff --diff-filter=ACMUXTR --name-only | grep -E "(${path})" || true)

if [[ -z $MODIFIED_FILE ]]; then
# Find unstaged changes
MODIFIED_FILE=$(git status --porcelain | awk '{ print $2 }' | grep -E "(${path})" || true)
fi

if [[ -n ${MODIFIED_FILE} ]]; then
echo "Found uncommited changes at: ${path}"
CHANGED_FILES+=("${path}")
Expand Down

0 comments on commit 97ba4cc

Please sign in to comment.