From 70e9b1ae0c65edf6a849664b0228720132f01b0e Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Tue, 12 Mar 2024 11:12:11 +0100 Subject: [PATCH] Use GitHub variables for Sonar (#86) * Use variables for Sonar * Update actions versions in maven.yml --- .github/workflows/maven.yml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e7de3c26..a6dc759a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -11,41 +11,42 @@ jobs: env: HAVE_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN != '' }} + HAVE_SONAR_DETAILS: ${{ vars.SONAR_PROJECTKEY != '' && vars.SONAR_ORGANIZATION != '' }} HAVE_DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN != '' }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Checkout omero-test-infra - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: openmicroscopy/omero-test-infra submodules: true path: .omero - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'adopt' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file - name: Cache SonarCloud packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache Maven packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }} - name: Login to Docker Hub if: ${{ env.HAVE_DOCKERHUB_TOKEN == 'true' }} - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -63,20 +64,20 @@ jobs: - name: Set folders ownership back to current user run: sudo chown -R $(id -u):$(id -g) $GITHUB_WORKSPACE && sudo chown -R $(id -u):$(id -g) $HOME - name: Sonar analysis - if: ${{ env.HAVE_SONAR_TOKEN == 'true' }} + if: ${{ env.HAVE_SONAR_TOKEN == 'true' && env.HAVE_SONAR_DETAILS == 'true' }} run: mvn sonar:sonar -Dsonar.host.url=$SONAR_URL -Dsonar.projectKey=$SONAR_PROJECTKEY -Dsonar.organization=$SONAR_ORGANIZATION env: - SONAR_PROJECTKEY: GReD-Clermont_simple-omero-client - SONAR_ORGANIZATION: gred-clermont - SONAR_URL: https://sonarcloud.io + SONAR_PROJECTKEY: ${{ vars.SONAR_PROJECTKEY }} + SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION }} + SONAR_URL: ${{ vars.SONAR_URL }} GITHUB_TOKEN: ${{ github.token }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - name: Upload to codecov after successful tests - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{secrets.CODECOV_TOKEN}} - name: Upload Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: jars path: | @@ -89,11 +90,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'adopt' @@ -101,7 +102,7 @@ jobs: gpg-private-key: ${{ secrets.GPG_KEY }} # Value of the GPG private key to import gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase - name: Cache Maven packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }}