Skip to content

Commit

Permalink
Create sonar.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
karen-avetisyan-mc authored Oct 31, 2024
1 parent ad19c24 commit 512b483
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Sonar
'on':
push:
branches:
- "**"
pull_request_target:
branches:
- "**"
types: [opened, synchronize, reopened, labeled]
schedule:
- cron: 0 16 * * *
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17
java-package: jdk

- uses: actions/checkout@v1
with:
fetch-depth: 0

- name: Check for external PR
if: ${{ !(contains(github.event.pull_request.labels.*.name, 'safe') ||
github.event.pull_request.head.repo.full_name == github.repository ||
github.event_name != 'pull_request_target') }}
run: echo "Unsecure PR, must be labelled with the 'safe' label, then run the workflow again" && exit 1

- name: Build with Maven

mvn clean install

- name: Sonar Scan
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
SONAR_TOKEN: '${{ secrets.SONAR_TOKEN }}'
run: >-
mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
-Dsonar.projectName=client-encryption-java
-Dsonar.projectKey=Mastercard_client-encryption-java
-Dsonar.organization=mastercard -Dsonar.host.url=https://sonarcloud.io
-Dsonar.login=$SONAR_TOKEN -Dsonar.cpd.exclusions=**/OkHttp*.java
-Dsonar.exclusions=**/*.xml -Dgpg.signature.skip=true

0 comments on commit 512b483

Please sign in to comment.