Skip to content

Commit

Permalink
chore: Update test.yml to handle changes in client/apps/ directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggling committed Sep 11, 2024
1 parent 14f8bb6 commit a664153
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all commit history for proper comparison
fetch-depth: 0 # Fetch all commit history for accurate comparison

- name: Fetch all branches
run: git fetch --all # Ensure all branches are fetched
- name: Fetch base and head branches
run: |
# Fetch the base branch explicitly (e.g., 'main')
git fetch origin ${{ github.base_ref }}
# Fetch the head branch (current branch in the workflow context)
git fetch origin ${{ github.head_ref }}
- name: Check for changes in /client/apps
id: check_changes
run: |
# Check if we're in a pull request or push context
# Compare base and head refs for pull requests
if [ "${{ github.event_name }}" == "pull_request" ]; then
# For pull requests, compare the base and head refs
git diff --name-only origin/${{ github.base_ref }}...${{ github.head_ref }} | grep -q "^client/apps/"
# Use the fetched branches for comparison
git diff --name-only origin/${{ github.base_ref }}...origin/${{ github.head_ref }} | grep -q "^client/apps/"
else
# For push events, compare with the previous commit
# For push events, compare the last commit with the previous commit
git diff --name-only HEAD^ HEAD | grep -q "^client/apps/"
fi
# Check the result of the previous command
if [ $? -eq 0 ]; then
echo "Changes detected in client/apps/"
echo "::set-output name=changes_detected::true"
Expand Down

0 comments on commit a664153

Please sign in to comment.