Skip to content

Commit

Permalink
Merge pull request #70 from sparrowapp-dev/sonarqube
Browse files Browse the repository at this point in the history
Sonarqube
  • Loading branch information
punitkashyup authored Oct 15, 2024
2 parents 34ed987 + f561e7e commit fa9a0dd
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Sonarqube

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main

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 }}"
2 changes: 2 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

sonar.projectKey=sparrow-app-auth

0 comments on commit fa9a0dd

Please sign in to comment.