Skip to content

Commit

Permalink
Run SonarCloud workflow after build
Browse files Browse the repository at this point in the history
Signed-off-by: Clara De Smet <[email protected]>
  • Loading branch information
clara-de-smet committed Sep 30, 2024
1 parent 64721fa commit e75cba9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
name: SonarCloud analysis

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_run:
workflows: [Build]
types: [completed]
workflow_dispatch:

permissions:
Expand All @@ -45,8 +44,16 @@ permissions:
jobs:
Analysis:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event.workflow_run.conclusion == 'success'

steps:
# Checkout main to get access to the SONAR_TOKEN. PR from forked repo does not have access to it.
- uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- name: Analyze with SonarCloud
if: ${{ github.actor != 'dependabot[bot]' }}
# You can pin the exact commit or the version.
Expand All @@ -62,6 +69,10 @@ jobs:
-Dsonar.projectKey=OpenSTEF_openstef
-Dsonar.organization=openstef
-Dsonar.verbose=true
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
-Dsonar.pullrequest.key=${{ github.event.workflow_run.pull_requests[0].number }}
-Dsonar.pullrequest.branch=${{ github.event.workflow_run.pull_requests[0].head.ref }}
-Dsonar.pullrequest.base=${{ github.event.workflow_run.pull_requests[0].base.ref }}
# Comma-separated paths to directories containing main source files.
#-Dsonar.sources= # optional, default is project base directory
# Comma-separated paths to directories containing test source files.
Expand Down

0 comments on commit e75cba9

Please sign in to comment.