Ver código fonte

Rearrange SonarCloud scan conditions.

Replace hack that checked out main (regardless of what branch the request was for) before the SonarCloud scan with a condition to only run SonarCloud on main branch.
Add check that the repository is make-all/tuya-local, as me pushing rebases to
pull requests is triggering the scan, which then runs without a token since it is using the source repository config.
Jason Rumney 3 anos atrás
pai
commit
d9cbf344fe
1 arquivos alterados com 1 adições e 4 exclusões
  1. 1 4
      .github/workflows/tests.yml

+ 1 - 4
.github/workflows/tests.yml

@@ -23,12 +23,9 @@ jobs:
           pip install -r requirements-dev.txt
       - name: Test with pytest
         run: pytest --cov=. --cov-config=.coveragerc --cov-report xml:coverage.xml
-      - name: Track master branch
-        if: github.event.sender.login == github.event.repository.owner.login
-        run: git fetch --no-tags https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY +refs/heads/main:refs/remotes/origin/main
       - name: SonarCloud scan
         uses: sonarsource/sonarcloud-github-action@master
-        if: github.event.sender.login == github.event.repository.owner.login
+        if: (github.event.sender.login == github.event.repository.owner.login) && (github.repository == "make-all/tuya-local") && (github.ref == "main")
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}