diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c74db20..df079d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,11 +3,15 @@ name: Timeless CI - Build & Publish on: push: branches: [ "main" ] - paths-ignore: + paths: + - 'timeless-api/**' + - 'whatsapp/**' - 'infrastructure/**' pull_request: branches: [ "main" ] - paths-ignore: + paths: + - 'timeless-api/**' + - 'whatsapp/**' - 'infrastructure/**' permissions: @@ -21,8 +25,13 @@ env: PUBLISH: ${{ github.repository == 'mcruzdev/timeless' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} jobs: + detect-changes: + uses: ./.github/workflows/detect_changes.yml + timeless-api: name: Build & Publish - Timeless API (Java) + needs: detect-changes + if: needs.detect-changes.outputs.api == 'true' runs-on: ubuntu-latest defaults: run: @@ -84,6 +93,8 @@ jobs: whatsapp: name: Build & Publish - WhatsApp Bot (Node.js) + needs: detect-changes + if: needs.detect-changes.outputs.whatsapp == 'true' runs-on: ubuntu-latest defaults: run: diff --git a/.github/workflows/detect_changes.yml b/.github/workflows/detect_changes.yml new file mode 100644 index 0000000..c34c1ac --- /dev/null +++ b/.github/workflows/detect_changes.yml @@ -0,0 +1,32 @@ +name: Detect Changed Paths + +on: + workflow_call: + outputs: + api: + description: Whether API paths changed + value: ${{ jobs.changes.outputs.api }} + whatsapp: + description: Whether WhatsApp paths changed + value: ${{ jobs.changes.outputs.whatsapp }} + +jobs: + changes: + name: Detect changed paths + runs-on: ubuntu-latest + outputs: + api: ${{ steps.filter.outputs.api }} + whatsapp: ${{ steps.filter.outputs.whatsapp }} + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Filter paths + id: filter + uses: dorny/paths-filter@v3 + with: + filters: | + api: + - 'timeless-api/**' + whatsapp: + - 'whatsapp/**' diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index cab24c8..068d6ea 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -3,7 +3,9 @@ name: Timeless CI - Pull Request Build on: pull_request: branches: [ "main" ] - paths-ignore: + paths: + - 'timeless-api/**' + - 'whatsapp/**' - 'infrastructure/**' permissions: @@ -14,8 +16,13 @@ concurrency: cancel-in-progress: true jobs: + detect-changes: + uses: ./.github/workflows/detect_changes.yml + timeless-api: name: Build Timeless API (Backend) + needs: detect-changes + if: needs.detect-changes.outputs.api == 'true' runs-on: ubuntu-latest defaults: run: @@ -56,6 +63,8 @@ jobs: whatsapp: name: Build WhatsApp Bot (Node.js) + needs: detect-changes + if: needs.detect-changes.outputs.whatsapp == 'true' runs-on: ubuntu-latest defaults: run: