4
0
Эх сурвалжийг харах

Change condition for running SonarCloud scan.

Repository owner is me even when other users make a pull request, but contrary to SonarCloud docs, it does not use my repository's sonar token for pull requests.
Change the condition to basically check if the repository owner is the actor.
This allows others to set up SonarCloud on their forked repos if they want to
check their own code, but stops the errors from SonarCloud auth in pull requests.
Jason Rumney 3 жил өмнө
parent
commit
2f76823751

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

@@ -25,10 +25,11 @@ jobs:
       - name: Test with pytest
       - name: Test with pytest
         run: pytest --cov=. --cov-config=.coveragerc --cov-report xml:coverage.xml
         run: pytest --cov=. --cov-config=.coveragerc --cov-report xml:coverage.xml
       - name: Track master branch
       - 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
         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
       - name: SonarCloud scan
         uses: sonarsource/sonarcloud-github-action@master
         uses: sonarsource/sonarcloud-github-action@master
-        if: github.event.repository.owner.login == 'make-all'
+        if: github.event.sender.login == github.event.repository.owner.login
         env:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}