From c3a5618a500cfb067e5fd9a61a2aaf2e97ab061d Mon Sep 17 00:00:00 2001 From: Stefan Krawczyk Date: Tue, 23 Apr 2024 22:53:28 -0700 Subject: [PATCH] Simplifies github actions for UI Github actions can filter on changes based on directory path. --- .github/workflows/hamilton-ui-backend.yml | 31 ++++------------------ .github/workflows/hamilton-ui-frontend.yml | 27 +------------------ 2 files changed, 6 insertions(+), 52 deletions(-) diff --git a/.github/workflows/hamilton-ui-backend.yml b/.github/workflows/hamilton-ui-backend.yml index b7d5d9bf5..66232e3f0 100644 --- a/.github/workflows/hamilton-ui-backend.yml +++ b/.github/workflows/hamilton-ui-backend.yml @@ -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: diff --git a/.github/workflows/hamilton-ui-frontend.yml b/.github/workflows/hamilton-ui-frontend.yml index ddcec5dae..019898825 100644 --- a/.github/workflows/hamilton-ui-frontend.yml +++ b/.github/workflows/hamilton-ui-frontend.yml @@ -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: