Skip to content

Commit

Permalink
Merge pull request #5 from rostilos/sonarqube-source
Browse files Browse the repository at this point in the history
Sonarqube source
  • Loading branch information
rostilos authored Jan 17, 2025
2 parents f683c65 + 94f2767 commit 4f11e6d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
38 changes: 32 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@
name: Build

on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- 'sonarqube'
issue_comment:
types: [created]

jobs:
build:
name: Build and analyze
name: SonarQube analyze
if: github.event.issue.pull_request && contains(github.event.comment.body, '/sonar')
runs-on: ubuntu-latest

steps:
- name: Get PR branch
- uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch

- name: Checkout PR branch
- uses: actions/checkout@v4
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: SonarQube Scan
- uses: sonarsource/sonarqube-scan-action@v3
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ variables.SONAR_HOST_URL }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

- name: SonarQube Quality Gate
- uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Add comment to PR
- uses: actions/github-script@v6
if: always()
with:
script: |
const name = '${{ github.workflow }}';
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
const success = '${{ job.status }}' === 'success';
const body = `${name}: ${success ? 'succeeded ✅' : 'failed ❌'}\n${url}`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
1 change: 1 addition & 0 deletions auth.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
}
}
}

0 comments on commit 4f11e6d

Please sign in to comment.