Browse Source

Merge remote-tracking branch 'origin/master' into feature/own-logger

Dominik Fuchß 4 years ago
parent
commit
a716078ed2
2 changed files with 12 additions and 19 deletions
  1. 1 1
      .github/workflows/maven.yml
  2. 11 18
      .github/workflows/sonarcloud.yml

+ 1 - 1
.github/workflows/maven.yml

@@ -1,4 +1,4 @@
-name: CI Build
+name: Build
 
 on:
   push: 

+ 11 - 18
.github/workflows/sonarcloud.yml

@@ -1,35 +1,28 @@
-name: SonarCloud Scan
+name: SonarCloud Scan (triggered by maven.yml)
 
 on:
-  push:
-    branches: [ main, master ]
-  pull_request:
-    types: [opened, synchronize, reopened]
+  workflow_run:
+    workflows:
+      - Build
+    types:
+      - completed
+
 
 
   # Allows you to run this workflow manually from the Actions tab
   workflow_dispatch:
 
 jobs:
-  pre_job:
-    runs-on: ubuntu-latest
-    outputs:
-      should_skip: ${{ steps.skip_check.outputs.should_skip }}
-    steps:
-      - id: skip_check
-        uses: fkirc/skip-duplicate-actions@master
-        with:
-          concurrent_skipping: 'same_content_newer'
-          skip_after_successful_duplicate: 'true'
   sonar:
-    needs: pre_job
     name: SonarCloud Scan
     runs-on: ubuntu-latest
-    if: ${{ needs.pre_job.outputs.should_skip != 'true' && github.actor != 'dependabot[bot]' }}
+    if: ${{ github.actor != 'dependabot[bot]' && github.event.workflow_run.conclusion == 'success' }}
 
     steps:
       - uses: actions/checkout@v3
         with:
+          repository: ${{ github.event.workflow_run.head_repository.full_name }}
+          ref: ${{ github.event.workflow_run.head_branch }}
           fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
       - name: Set up JDK
         uses: actions/setup-java@v3
@@ -53,4 +46,4 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
-        run: mvn -U -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
+        run: mvn -Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }} -Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0] != null && github.event.workflow_run.pull_requests[0].number }} -Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0] != null && github.event.workflow_run.pull_requests[0].head.ref }} -Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0] != null && github.event.workflow_run.pull_requests[0].base.ref }} -U -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar