Update README.md #181
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarCloud Code Analysis | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
types: [opened, synchronize, reopened] | |
workflow_dispatch: | |
permissions: | |
pull-requests: read | |
jobs: | |
sonarcloud: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
node-version: [20] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install | |
- name: Test and coverage | |
run: pnpm test | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
with: | |
args: -Dsonar.projectKey=adroidea_bot | |
-Dsonar.organization=adroidea | |
- name: SonarCloud Quality Gate status | |
id: sonar_status | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
quality_gate_status=$(curl -s -u "${{ secrets.SONAR_TOKEN }}:" -X GET \ | |
"https://sonarcloud.io/api/qualitygates/project_status?projectKey=adroidea_bot") | |
echo "$quality_gate_status" | |
status=$(echo "$quality_gate_status" | cut -c 29-30) | |
echo "result=$status" >> "$GITHUB_OUTPUT" | |
echo "$status" | |
- name: Write to workflow job summary | |
run: | | |
SUMMARY=$'# Testing Job Summary\n## Résultat Sonar\n${{ steps.sonar_status.outputs.result == 'OK' }}' | |
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY |