🔧 chore(Project): Test configuration to execute sonar validation #2
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 | |
on: | |
push: | |
branches: | |
- aiccra-feature-A2-821-sonar # Solo ejecutará el flujo en esta rama | |
pull_request: | |
branches: | |
- aiccra-feature-A2-821-sonar # Solo ejecutará el flujo para pull requests en esta rama | |
jobs: | |
build: | |
name: Build and analyze | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Clonar repositorio completamente para el análisis | |
- name: Set up JDK 8 for build | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 8 | |
distribution: "temurin" | |
- name: Force Maven to update dependencies | |
run: mvn -B clean install -U | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v2 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Maven packages | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Build with Maven (Java 8) | |
run: mvn -B clean install | |
- name: Set up JDK 11 for SonarQube analysis | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 11 | |
distribution: "temurin" | |
- name: Verify SONAR_TOKEN | |
run: | | |
if [ -z "${{ secrets.SONAR_TOKEN }}" ]; then | |
echo "SONAR_TOKEN is not set or empty" | |
exit 1 | |
else | |
echo "SONAR_TOKEN is set" | |
fi | |
- name: Build and analyze with SonarCloud | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=CCAFS_MARLO |