Skip to content

Commit

Permalink
Merge pull request #23 from indexdata/add-sonarcloud-to-gh-workflow
Browse files Browse the repository at this point in the history
Add Sonarcloud to GH Actions workflow
  • Loading branch information
funkymalc authored Jun 27, 2024
2 parents 76c8c1e + 336df24 commit 6328e22
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ name: deploy

on:
push:

pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

env:
PUBLISH_BRANCH: 'development'
K8S_NAMESPACE: 'reshare'
K8S_DEPLOYMENT: 'mod-ncip-1-14-5'
REGISTRY: ghcr.io
Expand All @@ -23,8 +27,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
Expand All @@ -48,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 }}
Expand Down

0 comments on commit 6328e22

Please sign in to comment.