diff --git a/.github/workflows/CheckForChanges.yml b/.github/workflows/CheckForChanges.yml new file mode 100644 index 000000000..3327b0947 --- /dev/null +++ b/.github/workflows/CheckForChanges.yml @@ -0,0 +1,32 @@ +name: "Check for changes" + +on: + workflow_call: + outputs: + hasAzureChanges: + description: "Azure related files changed" + value: ${{ jobs.check-for-changes.outputs.hasAzureChanges }} + hasBackendChanges: + description: "Backend related files changed" + value: ${{ jobs.check-for-changes.outputs.hasBackendChanges }} + +jobs: + check-for-changes: + name: Filter + runs-on: ubuntu-latest + outputs: + hasBackendChanges: ${{ steps.paths-filter.outputs.backend == 'true' }} + hasAzureChanges: ${{ steps.paths-filter.outputs.azure == 'true' }} + steps: + - uses: actions/checkout@v4 + + - uses: dorny/paths-filter@v2 + id: paths-filter + with: + base: ${{ github.ref }} + filters: | + backend: + - 'src/**/*' + azure: + - '.azure/**/*' + # todo: add additional files that should trigger a build diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index 7ccbeafea..76a105651 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -34,7 +34,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: OIDC Login to Azure Public Cloud with AzPowershell + - name: OIDC Login to Azure Public Cloud uses: azure/login@v1 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} diff --git a/.github/workflows/PullRequest.yml b/.github/workflows/PullRequest.yml index a3ff87932..07d866432 100644 --- a/.github/workflows/PullRequest.yml +++ b/.github/workflows/PullRequest.yml @@ -7,12 +7,19 @@ on: - "tests/k6/**" jobs: + check-for-changes: + name: Check for changes + uses: ./.github/workflows/CheckForChanges.yml + build: uses: ./.github/workflows/BuildAndTest.yml + needs: ["check-for-changes"] + if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' }} - # todo: only if .azure-files are changed build-infrastructure: uses: ./.github/workflows/BuildInfrastructure.yml + needs: ["check-for-changes"] + if: ${{ needs.check-for-changes.outputs.hasAzureChanges == 'true' }} secrets: AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} diff --git a/.github/workflows/Workflow.yml b/.github/workflows/Workflow.yml index 20940253f..279ad4869 100644 --- a/.github/workflows/Workflow.yml +++ b/.github/workflows/Workflow.yml @@ -9,12 +9,18 @@ on: - "tests/k6/**" jobs: + check-for-changes: + name: Check for changes + uses: ./.github/workflows/CheckForChanges.yml + build-and-test: uses: ./.github/workflows/BuildAndTest.yml + needs: [check-for-changes] + if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' }} publish: - needs: [build-and-test] uses: ./.github/workflows/Publish.yml + needs: [build-and-test] secrets: GCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }} with: