From eead575f1f0f027b1d021a6ce48c0217fc1bb3bf Mon Sep 17 00:00:00 2001 From: gjraju1304 <113449851+gjraju1304@users.noreply.github.com> Date: Fri, 15 Dec 2023 13:12:31 +0530 Subject: [PATCH] Update sonarcloud.yml --- .github/workflows/sonarcloud.yml | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 732cadc1d..cd831a28b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -1,38 +1,49 @@ -# testing sonar name: SonarCloud on: - push: - branches: - - master pull_request: - types: [opened, synchronize, reopened] + types: [opened] + jobs: build: name: Build and analyze runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Checkout Repository + uses: actions/checkout@v2 + - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v2 with: java-version: 17 - distribution: 'zulu' # Alternative distribution options are available. + distribution: 'adopt' + - name: Cache SonarCloud packages - uses: actions/cache@v3 + uses: actions/cache@v2 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages - uses: actions/cache@v3 + uses: actions/cache@v2 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 + - name: Build and analyze env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 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."