From a1e65e117a2de6ebcbb3581756692a6e5ea9dfdb Mon Sep 17 00:00:00 2001 From: PradeepLaxakar Date: Fri, 11 Oct 2024 17:35:26 +0530 Subject: [PATCH 1/3] build: sonarqube --- .github/workflows/sonarqube.yml | 64 +++++++++++++++++++++++++++++++++ sonar-project.properties | 2 ++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/sonarqube.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..94e2db5 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,64 @@ +name: Sonarqube + +on: + pull_request: + types: [opened, synchronize, reopened] + branches: + - development + + workflow_dispatch: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + permissions: # permission to comment a PR + contents: read + pull-requests: write + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + + # If you wish to fail your job when the Quality Gate is red, uncomment the following lines. + # Check the Quality Gate status. + # - name: SonarQube Quality Gate check + # id: sonarqube-quality-gate-check + # uses: sonarsource/sonarqube-quality-gate-action@master + # # #Enforce a timeout to fail the step after a specific time. + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} # OPTIONAL + + # PR Decoration + - name: SonarQube Pull Request Comment + if: always() + uses: campos-pay/sonarqube-pr-comment@main + with: + sonar_token: ${{ secrets.SONAR_TOKEN }} + sonar_host_url: ${{ secrets.SONAR_HOST_URL }} + sonar_projectkey: ${{ vars.SONAR_PROJECT_KEY }} #github.event.repository.name + github-token: ${{ secrets.GITHUB_TOKEN }} + repo_name: ${{ github.repository }} + pr_number: ${{ github.event.pull_request.number }} + + - uses: phwt/sonarqube-quality-gate-action@v1 + id: quality-gate-check + with: + sonar-project-key: ${{ vars.SONAR_PROJECT_KEY }} + sonar-host-url: ${{ secrets.SONAR_HOST_URL }} + sonar-token: ${{ secrets.SONAR_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} #PR_GITHUB_TOKEN + + - name: Output result + run: | + echo "${{ steps.quality-gate-check.outputs.project-status }}" + echo "${{ steps.quality-gate-check.outputs.quality-gate-result }}" diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..493b7f3 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,2 @@ + +sonar.projectKey=sparrow-app-auth \ No newline at end of file From 7ffb289b4348012784edb012ceba1ea28c3f2eed Mon Sep 17 00:00:00 2001 From: PradeepLaxakar Date: Fri, 11 Oct 2024 17:47:32 +0530 Subject: [PATCH 2/3] build: sonarqube --- .github/workflows/sonarqube.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 94e2db5..71c2926 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -62,3 +62,4 @@ jobs: run: | echo "${{ steps.quality-gate-check.outputs.project-status }}" echo "${{ steps.quality-gate-check.outputs.quality-gate-result }}" + From f561e7eb33bedf015a79e2dcbe6637b3b7d16fce Mon Sep 17 00:00:00 2001 From: PradeepLaxakar Date: Fri, 11 Oct 2024 17:48:21 +0530 Subject: [PATCH 3/3] build: sonarqube --- .github/workflows/sonarqube.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 71c2926..3eeafd2 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -4,7 +4,7 @@ on: pull_request: types: [opened, synchronize, reopened] branches: - - development + - main workflow_dispatch: