Browse Source

Allow running sonar within PR of a fork (#1581)

* Allow running sonar within PR of a fork

* remove github token from envs on mvn verify
Ruslan Ibragimov 3 years ago
parent
commit
d503691600

+ 4 - 3
.github/workflows/backend.yml

@@ -1,6 +1,6 @@
 name: backend
 on:
-  pull_request:
+  pull_request_target:
     types: ['opened', 'edited', 'reopened', 'synchronize']
     paths:
       - 'kafka-ui-api/**'
@@ -32,6 +32,7 @@ jobs:
           restore-keys: ${{ runner.os }}-sonar
       - name: Build and analyze
         env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
-        run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
+        run: |
+          mvn versions:set -DnewVersion=$GITHUB_SHA
+          mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

+ 5 - 5
.github/workflows/e2e-checks.yaml

@@ -1,6 +1,6 @@
 name: e2e-checks
 on:
-  pull_request:
+  pull_request_target:
     types: [ 'opened', 'edited', 'reopened', 'synchronize' ]
     paths:
       - 'kafka-ui-api/**'
@@ -34,6 +34,7 @@ jobs:
       - name: Build with Maven
         id: build_app
         run: |
+          mvn versions:set -DnewVersion=$GITHUB_SHA
           mvn clean package -DskipTests ${{ github.event.inputs.extraMavenOptions }}
       - name: compose app
         id: compose_app
@@ -41,10 +42,9 @@ jobs:
         run: |
           docker-compose -f ./documentation/compose/kafka-ui-connectors.yaml up -d
       - name: e2e run
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
-          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
-        run: mvn -pl '!kafka-ui-api' test -Pprod
+        run: |
+          mvn versions:set -DnewVersion=$GITHUB_SHA
+          mvn -pl '!kafka-ui-api' test -Pprod
       - name: Generate allure report
         uses: simple-elf/allure-report-action@master
         if: always()

+ 1 - 1
.github/workflows/frontend.yaml

@@ -3,7 +3,7 @@ on:
   push:
     branches:
       - master
-  pull_request:
+  pull_request_target:
     types: ['opened', 'edited', 'reopened', 'synchronize']
     paths:
     - 'kafka-ui-contract/**'