Skip to content

Commit

Permalink
fix: no run on some condition
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 24, 2024
1 parent 69b16a3 commit ab7c2ae
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/actions/early-exit-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Check for early exit
description: |
This action checks for changes in specific directories and
exits early if there are none
runs:
using: composite
steps:
- name: Check location of changed files
shell: bash
run: |
change_count=$(git diff --name-only origin/main..HEAD | grep -E '^(app/.*)|(.yarn/.*)|(.github/workflows/.*)' | wc -l)
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
else
echo "result=true" >> $GITHUB_OUTPUT
fi
# - name: Record output
# if: env.output > 0
# shell: bash
# run: |
# echo "${{ env.output }} files changed in app, .yarn, or .github/workflows"
# echo "result=false" >> $GITHUB_OUTPUT
20 changes: 20 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ jobs:
runs-on: macos-13
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: Terminate workflow if early exit check passes
if: steps.should_early_exit.outputs.result == 'true'
run: |
exit 0
- uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -244,6 +255,15 @@ jobs:
steps:
- uses: actions/checkout@v4

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

- name: Terminate workflow if early exit check passes
if: steps.should_early_exit.outputs.result == 'true'
run: |
exit 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
Expand Down

0 comments on commit ab7c2ae

Please sign in to comment.