Update sonarcloud.yml

This commit is contained in:
gjraju1304 2023-12-15 13:12:31 +05:30 committed by GitHub
parent c251eea0d7
commit eead575f1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,38 +1,49 @@
# testing sonar
name: SonarCloud name: SonarCloud
on: on:
push:
branches:
- master
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened]
jobs: jobs:
build: build:
name: Build and analyze name: Build and analyze
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout Repository
with: uses: actions/checkout@v2
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v3 uses: actions/setup-java@v2
with: with:
java-version: 17 java-version: 17
distribution: 'zulu' # Alternative distribution options are available. distribution: 'adopt'
- name: Cache SonarCloud packages - name: Cache SonarCloud packages
uses: actions/cache@v3 uses: actions/cache@v2
with: with:
path: ~/.sonar/cache path: ~/.sonar/cache
key: ${{ runner.os }}-sonar key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages - name: Cache Maven packages
uses: actions/cache@v3 uses: actions/cache@v2
with: with:
path: ~/.m2 path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2 restore-keys: ${{ runner.os }}-m2
- name: Build and analyze - name: Build and analyze
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=jenkins-project-dec2023_webhooks run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=jenkins-project-dec2023_webhooks
create_pull_request:
needs: build
runs-on: ubuntu-latest
steps:
- name: Check SonarCloud status
run: echo "SonarCloud analysis was successful."
- name: Create Pull Request
if: ${{ success() && github.event_name == 'pull_request' }}
run: echo "Create pull request logic goes here."