From f24fd44a3a63bdc5db4caf8ae7bc97706b628f19 Mon Sep 17 00:00:00 2001 From: Phan An Date: Mon, 14 Nov 2022 15:05:11 +0100 Subject: [PATCH] feat(build): use path-filters --- ...d-pgsql.yml => unit-backend-pgsql.yml.bak} | 0 .github/workflows/unit-backend.yml | 38 ++++++++++++++--- .github/workflows/unit-frontend.yml | 41 ++++++++++++++----- .gitmodules | 0 4 files changed, 62 insertions(+), 17 deletions(-) rename .github/workflows/{unit-backend-pgsql.yml => unit-backend-pgsql.yml.bak} (100%) delete mode 100644 .gitmodules diff --git a/.github/workflows/unit-backend-pgsql.yml b/.github/workflows/unit-backend-pgsql.yml.bak similarity index 100% rename from .github/workflows/unit-backend-pgsql.yml rename to .github/workflows/unit-backend-pgsql.yml.bak diff --git a/.github/workflows/unit-backend.yml b/.github/workflows/unit-backend.yml index b9d65482..17564e0a 100644 --- a/.github/workflows/unit-backend.yml +++ b/.github/workflows/unit-backend.yml @@ -3,20 +3,38 @@ on: pull_request: branches: - master - paths-ignore: - - resources/assets/** push: branches: - master - paths-ignore: - - resources/assets/** workflow_dispatch: branches: - master - paths-ignore: - - resources/assets/** + jobs: + changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + changed: ${{ steps.filter.outputs.backend }} + steps: + - uses: actions/checkout@v2 + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + backend: + - '!./resources/assets/**' + - '!./.github/workflows/unit-frontend.yml' + - '!./vite.config.js' + - '!./package.json' + - '!./yarn.lock' + - '!./.eslintrc' + - '!./cypress.json' + test: + needs: changes + if: ${{needs.changes.outputs.changed == 'backend'}} runs-on: ubuntu-latest strategy: matrix: @@ -53,3 +71,11 @@ jobs: uses: codecov/codecov-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} + + skip: + name: Skip + runs-on: ubuntu-latest + if: ${{needs.changes.outputs.changed != 'backend'}} + steps: + - name: Skip + run: echo "No backend-related changes detected, skipping." diff --git a/.github/workflows/unit-frontend.yml b/.github/workflows/unit-frontend.yml index 7172c9b3..949b7ce1 100644 --- a/.github/workflows/unit-frontend.yml +++ b/.github/workflows/unit-frontend.yml @@ -3,29 +3,40 @@ on: pull_request: branches: - master - paths: - - resources/assets/** - - .github/workflows/unit-frontend.yml push: branches: - master - - next - paths: - - resources/assets/** - - .github/workflows/unit-frontend.yml workflow_dispatch: branches: - master - - next - paths: - - resources/assets/** - - .github/workflows/unit-frontend.yml env: LARAVEL_BYPASS_ENV_CHECK: 1 jobs: + changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + changed: ${{ steps.filter.outputs.backend }} + steps: + - uses: actions/checkout@v2 + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + frontend: + - './resources/assets/**' + - './vite.config.js' + - './package.json' + - './yarn.lock' + - './.eslintrc' + - './cypress.json' + test: + needs: changes + if: ${{needs.changes.outputs.changed == 'frontend'}} runs-on: ubuntu-latest strategy: fail-fast: false @@ -46,3 +57,11 @@ jobs: uses: codecov/codecov-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} + + skip: + needs: changes + if: ${{needs.changes.outputs.changed != 'frontend'}} + runs-on: ubuntu-latest + steps: + - name: Skip + run: echo "No frontend-related changes detected, skipping." diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29b..00000000