Browse Source

Sonar should now no longer run on pull requests from users that don't have the SONAR_TOKEN secret

Jorrit Rouwe 3 years ago
parent
commit
480033b36f
1 changed files with 13 additions and 0 deletions
  1. 13 0
      .github/workflows/sonar-cloud.yml

+ 13 - 0
.github/workflows/sonar-cloud.yml

@@ -15,8 +15,21 @@ on:
       - '**.txt'
 
 jobs:
+  check-secret:
+    runs-on: ubuntu-latest
+    outputs:
+      sonar-token: ${{ steps.sonar-token.outputs.defined }}
+    steps:
+      - id: sonar-token
+        if: ${{ env.SONAR_TOKEN != '' }}
+        run: echo "::set-output name=defined::true"
+        env:
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+          
   build:
     name: Build
+    needs: [check-secret]
+    if: needs.check-secret.outputs.sonar-token == 'true'
     runs-on: ubuntu-latest
     env:
       SONAR_SCANNER_VERSION: 4.7.0.2747