diff --git a/.github/workflows/backend-code-checks.yml b/.github/workflows/backend-code-checks.yml index 32fd3ed3940..b33e2c259ba 100644 --- a/.github/workflows/backend-code-checks.yml +++ b/.github/workflows/backend-code-checks.yml @@ -14,12 +14,31 @@ on: - 'docs/**' - 'latest.json' -permissions: - contents: read - id-token: write - jobs: + detect-changes: + name: Detect whether code changed + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + changed: ${{ steps.detect-changes.outputs.backend }} + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: true # required to get more history in the changed-files action + fetch-depth: 2 + - name: Detect changes + id: detect-changes + uses: ./.github/actions/change-detection + with: + self: .github/workflows/backend-code-checks.yml + validate-configs: + permissions: + contents: read + id-token: write + needs: detect-changes + if: needs.detect-changes.outputs.changed == 'true' name: Validate Backend Configs runs-on: ubuntu-latest steps: diff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.yml index f870c16a847..ec9bfc62bec 100644 --- a/.github/workflows/go-lint.yml +++ b/.github/workflows/go-lint.yml @@ -13,7 +13,27 @@ permissions: contents: read jobs: + detect-changes: + name: Detect whether code changed + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + changed: ${{ steps.detect-changes.outputs.backend }} + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: true # required to get more history in the changed-files action + fetch-depth: 2 + - name: Detect changes + id: detect-changes + uses: ./.github/actions/change-detection + with: + self: .github/workflows/go-lint.yml + lint-go: + needs: detect-changes + if: needs.detect-changes.outputs.changed == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/swagger-gen.yml b/.github/workflows/swagger-gen.yml index 0e42e0e7441..9399a366933 100644 --- a/.github/workflows/swagger-gen.yml +++ b/.github/workflows/swagger-gen.yml @@ -14,10 +14,29 @@ concurrency: cancel-in-progress: true jobs: + detect-changes: + name: Detect whether code changed + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + changed: ${{ steps.detect-changes.outputs.backend }} + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: true # required to get more history in the changed-files action + fetch-depth: 2 + - name: Detect changes + id: detect-changes + uses: ./.github/actions/change-detection + with: + self: .github/workflows/swagger-gen.yml + verify: name: Verify committed API specs match runs-on: ubuntu-latest - if: ${{ github.repository == 'grafana/grafana' }} + needs: detect-changes + if: github.repository == 'grafana/grafana' && needs.detect-changes.outputs.changed == 'true' permissions: contents: read # clone the repository id-token: write # required for Vault access