phwt / sonarqube-quality-gate-action

Check quality gate result from latest analysis and report result in the pull request's comment
MIT License
10 stars 10 forks source link

Add Support to Retrieve the Pull Request's Quality Status #25

Closed xuanan93 closed 1 month ago

xuanan93 commented 3 months ago

Please update get PR, currently I see your project only get status of branch. /dashboard?id=repo&branch=develop I am using PR so I can't get report, can you add get PR, the URL will be like this dashboard?id=repo&pullRequest=69.

Thanks,

phwt commented 1 month ago

Hi @xuanan93! You can use branch input to specify the branch that this action will get the quality status from, you can configure the action similar to the below:

jobs:
  sonarqube:
    runs-on: ubuntu-latest
    steps:
      - uses: phwt/sonarqube-quality-gate-action@v1
        id: quality-gate-check
        with:
          sonar-project-key: ${{ secrets.SONAR_PROJECT_KEY }}
          sonar-host-url: ${{ secrets.SONAR_HOST_URL }}
          sonar-token: ${{ secrets.SONAR_TOKEN }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
+         branch: main

In the background, this action will call the GET /api/qualitygates/project_status endpoint to retrieve the quality gate status, if the branch input is specified, the action will append the branch parameter to this endpoint, similar to the below:

GET /api/qualitygates/project_status?projectKey=your-project-key&branch=your-branch

For reference, the request to SonarQube API is handled in src/modules/sonarqube-api.ts file.

phwt commented 1 month ago

Hi again @xuanan93, I was sleepy and read your issue wrong, the support for pull request will be released with #30