Skip to content

Create main.yml

Create main.yml #1

Workflow file for this run

name: SonarQube Scan
on:
push:
branches:
- main
pull_request:
branches:
- '**'
jobs:
sonarQube:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up JDK 22
uses: actions/setup-java@v2
with:
java-version: '22'
- name: Cache SonarQube packages
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar-cache
restore-keys: |
${{ runner.os }}-sonar-cache
- name: SonarQube Scan
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn clean verify sonar:sonar -Dsonar.projectKey=<your_project_key> -Dsonar.host.url=<your_sonarqube_server_url> -Dsonar.login=${{ secrets.SONAR_TOKEN }}
- name: Upload SonarQube results
if: always()
run: |
echo "Uploading SonarQube results"