Skip to content

Commit

Permalink
fix: pipe logic
Browse files Browse the repository at this point in the history
Signed-off-by: Jason C. Leach <[email protected]>
  • Loading branch information
jleach committed Oct 25, 2024
1 parent 2a7c6f3 commit f85df62
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions .github/workflows/actions/early-exit-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,30 @@ runs:
- name: Check location of changed files
shell: bash
run: |
# On main branch, compare with the previous
# commit otherwise (for PRs) compare with the
# current commit.
if [ "${GITHUB_REF_NAME}" = "main" ]; then
end_ref="HEAD^"
set -x
if [ "${GITHUB_REF_NAME}" = "main" ]; then
# On main branch, compare with the previous
# commit otherwise (for PRs) compare with the
# current commit.
parent_ref="${GITHUB_REF_NAME}^"
child_ref="${GITHUB_SHA}"
else
end_ref="HEAD"
# On PRs, compare with the base branch.
parent_ref="origin/${GITHUB_BASE_REF:-main}"
child_ref="HEAD"
fi
echo "Comparing origin/${GITHUB_BASE_REF:-HEAD} with ${end_ref}"
echo "Comparing ${parent_ref} with ${child_ref}"
change_count=$(git diff --name-only origin/${GITHUB_BASE_REF:-HEAD}..${end_ref} | grep -E '^(app/.*)|(.yarn/.*)|(.github/workflows/.*)' | wc -l | awk '{$1=$1};1')
change_count=$(
git diff --name-only $parent_ref..$child_ref | \
grep -E '^(app/.*)|(.yarn/.*)|(.github/workflows/.*)' || true | \
wc -l | \
awk '{$1=$1};1'
)
echo "$change_count files changed in app, .yarn, or .github/workflows"
if [ $change_count -gt 0 ]; then
# A result greater than 0 means there are changes
# in the specified directories.
Expand Down

0 comments on commit f85df62

Please sign in to comment.