From 8ff74ba8d0c6d19f0c00311c7f03c812c8f48a93 Mon Sep 17 00:00:00 2001 From: John Malconian Date: Thu, 27 Jun 2024 09:52:51 -0400 Subject: [PATCH 1/2] add sonarcloud to actions workflow --- .github/workflows/build-deploy.yml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 74696fe..2e3c87b 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -2,7 +2,10 @@ name: deploy on: push: - + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + env: K8S_NAMESPACE: 'reshare' K8S_DEPLOYMENT: 'mod-ncip-1-14-5' @@ -23,8 +26,28 @@ jobs: java-version: '17' distribution: 'adopt' + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build with Maven - run: mvn clean install + run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install org.jacoco:jacoco-maven-plugin:report + + - name: SQ analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=indexdata -Dsonar.projectKey=indexdata_${{ github.event.repository.name }} - name: Log in to the Container registry uses: docker/login-action@v2 From 336df2463058f2c63ac27afbd06087f9a409386d Mon Sep 17 00:00:00 2001 From: John Malconian Date: Thu, 27 Jun 2024 09:57:14 -0400 Subject: [PATCH 2/2] only deploy to K8s if branch is 'PUBLISH_BRANCH' --- .github/workflows/build-deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 2e3c87b..d62be3b 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -7,6 +7,7 @@ on: workflow_dispatch: env: + PUBLISH_BRANCH: 'development' K8S_NAMESPACE: 'reshare' K8S_DEPLOYMENT: 'mod-ncip-1-14-5' REGISTRY: ghcr.io @@ -71,6 +72,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - name: Deploy latest to K8s + if: ${{ env.CURRENT_BRANCH == env.PUBLISH_BRANCH }} uses: actions-hub/kubectl@v1.21.2 env: KUBE_CONFIG: ${{ secrets.RESHARE_DEV_SA_KUBECONFIG }}