Skip to content

Commit

Permalink
Simplifies github actions for UI
Browse files Browse the repository at this point in the history
Github actions can filter on changes based on directory path.
  • Loading branch information
skrawcz committed Apr 24, 2024
1 parent aacfbe6 commit c3a5618
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 52 deletions.
31 changes: 5 additions & 26 deletions .github/workflows/hamilton-ui-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,18 @@ on:
push:
branches:
- main # or any specific branches you want to include
paths:
- 'ui/backend/**'

pull_request:
branches:
- main
paths:
- 'ui/backend/**'


jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2 # fetch previous commit for comparison
- id: filter
run: |
echo "Checking for changes in the backend directory and branch..."
# Check if the current branch is not main
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then
# Check for changes in the backend directory
if git diff --quiet HEAD^ HEAD -- ui/backend/; then
echo "::set-output name=skip::true"
echo "No changes in backend/ or not on main branch, skipping subsequent jobs."
else
echo "::set-output name=skip::false"
echo "Changes detected in backend/ and not on main branch."
fi
else
echo "::set-output name=skip::false"
echo "On main branch, proceeding with subsequent jobs."
fi
test-backend:
needs: check-changes
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
27 changes: 1 addition & 26 deletions .github/workflows/hamilton-ui-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,13 @@ on:
branches:
- main
paths:
- 'ui/**'
- 'ui/frontend/**'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'ui/frontend/**'

jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2 # fetch previous commit for comparison
- id: filter
run: |
echo "Checking for changes in the frontend directory and branch..."
# Check if the current branch is not main
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then
# Check for changes in the frontend directory
if git diff --quiet HEAD^ HEAD -- ui/frontend/; then
echo "::set-output name=skip::true"
echo "No changes in frontend/ or not on main branch, skipping subsequent jobs."
else
echo "::set-output name=skip::false"
echo "Changes detected in frontend/ and not on main branch."
fi
else
echo "::set-output name=skip::false"
echo "On main branch, proceeding with subsequent jobs."
fi
build:
runs-on: ubuntu-latest
defaults:
Expand Down

0 comments on commit c3a5618

Please sign in to comment.