Bump appleboy/ssh-action from 1.0.3 to 1.2.3 #340
Workflow file for this run
This file contains hidden or 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: | |
| CI & SonarQube | |
| on: | |
| push: | |
| branches: [ "**" ] | |
| pull_request: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build-test-and-analyze: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Sonar cần có full history để tính "blame" | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| cache: 'maven' | |
| - name: Build & Test | |
| run: mvn -B -DskipTests=false -Dmaven.test.failure.ignore=true verify | |
| - name: Upload Surefire reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: surefire-reports | |
| path: | | |
| **/target/surefire-reports/** | |
| **/target/failsafe-reports/** | |
| if-no-files-found: ignore | |
| - name: SonarQube / SonarCloud Scan | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }} | |
| SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
| SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }} | |
| SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY_BACKEND }} | |
| run: | | |
| if [ -z "$SONAR_TOKEN" ] || [ -z "$SONAR_HOST_URL" ]; then | |
| echo "SONAR_* secrets chưa được cấu hình => bỏ qua phân tích Sonar." | |
| exit 0 | |
| fi | |
| # Đường dẫn report JaCoCo aggregate (được tạo ở bước 'verify' của root pom) | |
| JACOCO_XML="target/site/jacoco-aggregate/jacoco.xml" | |
| if echo "$SONAR_HOST_URL" | grep -qi "sonarcloud.io"; then | |
| # SonarCloud cần organization + projectKey | |
| if [ -z "$SONAR_ORGANIZATION" ] || [ -z "$SONAR_PROJECT_KEY" ]; then | |
| echo "Thiếu SONAR_ORGANIZATION hoặc SONAR_PROJECT_KEY cho SonarCloud." | |
| exit 1 | |
| fi | |
| mvn -B -DskipTests=true \ | |
| -Dsonar.organization="$SONAR_ORGANIZATION" \ | |
| -Dsonar.projectKey="$SONAR_PROJECT_KEY" \ | |
| -Dsonar.coverage.jacoco.xmlReportPaths="$JACOCO_XML" \ | |
| sonar:sonar | |
| else | |
| # SonarQube self-hosted: KHÔNG dùng sonar.organization | |
| mvn -B -DskipTests=true \ | |
| -Dsonar.coverage.jacoco.xmlReportPaths="$JACOCO_XML" \ | |
| sonar:sonar | |
| fi | |