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 17b56ac
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 32 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/actions/early-exit-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,32 @@ 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:-main}^"
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}"
diff_output=$(git diff --name-only ${parent_ref}..${child_ref})
# change_count=$(echo "$diff_output" | grep -E '^(app/.*)|(.yarn/.*)|(.github/workflows/.*)' | wc -l | awk '{$1=$1};1' || true)
change_count=$(echo "$diff_output" | grep -E '^(blarb/.*)' | wc -l | awk '{$1=$1};1' || true)
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')
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.
echo "result=false" >> $GITHUB_OUTPUT
echo "result=zz" >> $GITHUB_OUTPUT
else
echo "result=true" >> $GITHUB_OUTPUT
echo "result=xx" >> $GITHUB_OUTPUT
fi
66 changes: 44 additions & 22 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,54 @@ jobs:
MEDIATOR_USE_PUSH_NOTIFICATIONS: ${{ vars.MEDIATOR_USE_PUSH_NOTIFICATIONS }}
INDY_VDR_PROXY_URL: ${{ vars.INDY_VDR_PROXY_URL }}

build-ios:
needs: [check-secrets, check-vars]
runs-on: macos-13
early-exit-check:
runs-on: ubuntu-22.04
outputs:
should_skip_build: ${{ steps.core_files_check.outputs.result != 'true' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all branches, main needed.

- name: Run early exit check
id: should_early_exit
uses: ./.github/workflows/actions/early-exit-check

- name: Exit if no changes in core paths
if: steps.should_early_exit.outputs.result == 'true'
- name: Check if core files changed
id: core_files_check
shell: bash
run: |
exit 0
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:-main}^"
child_ref="${GITHUB_SHA}"
else
# On PRs, compare with the base branch.
parent_ref="origin/${GITHUB_BASE_REF:-main}"
child_ref="HEAD"
fi
echo "Comparing ${parent_ref} with ${child_ref}"
diff_output=$(git diff --name-only ${parent_ref}..${child_ref})
change_count=$(echo "$diff_output" | grep -E '^(app/.*)|(.yarn/.*)|(.github/workflows/.*)' | wc -l | awk '{$1=$1};1' || true)
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.
echo "result=true" >> $GITHUB_OUTPUT
else
echo "result=false" >> $GITHUB_OUTPUT
fi
build-ios:
needs: [check-secrets, check-vars, early-exit-check]
if: ${{ needs.early-exit-check.outputs.should_skip_build != 'true' }}
runs-on: macos-13
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -237,24 +269,14 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}

build-android:
needs: [check-secrets, check-vars]
needs: [check-secrets, check-vars, early-exit-check]
if: ${{ needs.early-exit-check.outputs.should_skip_build != 'true' }}
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all branches, main needed.

- name: Run early exit check
id: should_early_exit
uses: ./.github/workflows/actions/early-exit-check

- name: Exit if no changes in core paths
if: steps.should_early_exit.outputs.result == 'true'
run: |
exit 0

- uses: actions/setup-python@v5
with:
Expand Down

0 comments on commit 17b56ac

Please sign in to comment.