diff --git a/.github/workflows/check-proto-break.yml b/.github/workflows/check-proto-break.yml index d293d29524..d1aeac0c97 100644 --- a/.github/workflows/check-proto-break.yml +++ b/.github/workflows/check-proto-break.yml @@ -8,7 +8,25 @@ on: - edited jobs: + check-if-code-change: + runs-on: ubuntu-latest + outputs: + change: ${{ steps.check.outputs.change }} + steps: + - uses: actions/checkout@v4 + with: + go-version: '1.20' + fetch-depth: 0 + - run: | + if git --no-pager diff --exit-code origin/main...HEAD -- . ':!docs' ':!*.md'; then + echo "::set-output name=change::false" + else + echo "::set-output name=change::true" + fi + id: check check-proto-break: + needs: check-if-code-change + if: ${{ needs.check-if-code-change.outputs.change == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/setup-go@v3 diff --git a/.github/workflows/gofmt.yml b/.github/workflows/gofmt.yml index f9da39a006..9a558047c4 100644 --- a/.github/workflows/gofmt.yml +++ b/.github/workflows/gofmt.yml @@ -11,7 +11,25 @@ on: merge_group: jobs: + check-if-code-change: + runs-on: ubuntu-latest + outputs: + change: ${{ steps.check.outputs.change }} + steps: + - uses: actions/checkout@v4 + with: + go-version: '1.20' + fetch-depth: 0 + - run: | + if git --no-pager diff --exit-code origin/main...HEAD -- . ':!docs' ':!*.md'; then + echo "::set-output name=change::false" + else + echo "::set-output name=change::true" + fi + id: check gofmt: + needs: check-if-code-change + if: ${{ needs.check-if-code-change.outputs.change == 'true' }} name: gofmt runs-on: ubuntu-latest steps: diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 7d837605f4..7c8da0864d 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,7 +21,25 @@ env: GOLINT_VERSION: v1.53.3 jobs: + check-if-code-change: + runs-on: ubuntu-latest + outputs: + change: ${{ steps.check.outputs.change }} + steps: + - uses: actions/checkout@v4 + with: + go-version: '1.20' + fetch-depth: 0 + - run: | + if git --no-pager diff --exit-code origin/main...HEAD -- . ':!docs' ':!*.md'; then + echo "::set-output name=change::false" + else + echo "::set-output name=change::true" + fi + id: check golangci: + needs: check-if-code-change + if: ${{ needs.check-if-code-change.outputs.change == 'true' }} name: golang-lint runs-on: ubuntu-latest steps: