浏览代码

Skip sonar scan if build skipped (#546)

* Skip sonar scan if build skipped

* Update sonarcloud-pr.yml
Dominik Fuchß 4 年之前
父节点
当前提交
67fc4ed05a
共有 1 个文件被更改,包括 10 次插入 和 1 次删除
  1. 10 1
      .github/workflows/sonarcloud-pr.yml

+ 10 - 1
.github/workflows/sonarcloud-pr.yml

@@ -27,6 +27,8 @@ jobs:
       pullRequestLabels: ${{ steps.source-run-info.outputs.pullRequestLabels }}
       targetBranch: ${{ steps.source-run-info.outputs.targetBranch }}
       sourceEvent: ${{ steps.source-run-info.outputs.sourceEvent }}
+      # Get the information about the build job of the maven.yml workflow
+      buildResult: ${{ fromJson(steps.get_jobs_of_parent.outputs.data).jobs[1].conclusion }}
     steps:
       - name: "Get information about the origin 'CI' run"
         uses: potiuk/get-workflow-origin@v1_3
@@ -34,11 +36,18 @@ jobs:
         with:
           token: ${{ secrets.GITHUB_TOKEN }}
           sourceRunId: ${{ github.event.workflow_run.id }}
+      - name: Get Workflow Run
+        uses: octokit/request-action@v2.1.0
+        id: get_jobs_of_parent
+        with:
+          route: GET /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/jobs
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
   sonar:
     name: SonarCloud Scan
     runs-on: ubuntu-latest
-    if: ${{ needs.get-info.outputs.sourceEvent == 'pull_request' && github.actor != 'dependabot[bot]' && github.event.workflow_run.conclusion == 'success' }}
+    if: ${{ needs.get-info.outputs.sourceEvent == 'pull_request' && github.actor != 'dependabot[bot]' && github.event.workflow_run.conclusion == 'success' && needs.get-info.outputs.buildResult == 'success' }}
     needs: get-info
 
     steps: