Skip to content
Snippets Groups Projects
Commit 5fc54ae3 authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

initial release.

parent 3a2dc0aa
Branches master
Tags 0.0.3
No related merge requests found
name: 'Java CI Sonar'
description: 'Run sonar against Build a Java CI project with maven and Docker'
runs:
using: "composite"
steps:
# build the project in a docker container with a specific maven settings.xml
# it uses env variables from github secrets for the credentials
# to github, dockerhub and sonar.
- name: run sonar with Maven in docker
run: ${{ github.action_path }}/mvn.sh sonar:sonar -D sonar.branch.name=$(git rev-parse --abbrev-ref HEAD|tr / _ ) -DskipTests=true -Dsonar.language=java -Dsonar.report.export.path=sonar-report.json -Dsonar.host.url=${{ env.SONAR_URL }} --activate-profiles sonar
shell: bash
- name: Deploy Maven Artifacts
run: ${{ github.action_path }}/mvn.sh deploy
shell: bash
- name: Notify dedicated teams channel of Success
uses: dragos-cojocari/ms-teams-notification@v1.0.0
if: ${{ success() }}
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ env.MSTEAMS_WEBHOOK }}
notification-summary: Sonar success.
notification-color: 28a745
timezone: Europe/Paris
- name: Notify dedicated teams channel of Failure
uses: dragos-cojocari/ms-teams-notification@v1.0.0
if: ${{ failure() }}
with:
github-token: ${{ github.token }} # this will use the runner's token.
ms-teams-webhook-uri: ${{ env .MSTEAMS_WEBHOOK }}
notification-summary: Sonar failure.
notification-color: dc3545
timezone: Europe/Paris
mvn versions:display-dependency-updates
mvn versions:display-plugin-updates
mvn versions:display-property-updates
<!-- A MAVEN SETTINGS FILE TO BE USED IN CI -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>${env.GITHUBLOGIN}</username>
<password>${env.GITHUBPASSWORD}</password>
</server>
<server>
<id>dockerhub</id>
<username>${env.DOCKER_USERNAME}</username>
<password>${env.DOCKER_PASSWORD}</password>
</server>
<server>
<id>github.pages</id>
<username>git</username>
<configuration>
<scmVersionType>branch</scmVersionType>
<scmVersion>gh-pages</scmVersion>
</configuration>
</server>
</servers>
<profiles>
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>${env.SONAR_URL}</sonar.host.url>
<sonar.login>${env.SONAR_TOKEN}</sonar.login>
</properties>
</profile>
</profiles>
</settings>
mvn.sh 0 → 100755
#!/bin/bash
export MAVEN_IMAGE=brunoe/maven:3.8.6-eclipse-temurin-17
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CURRENT=$(pwd)
echo SCRIPT_DIR=$SCRIPT_DIR
echo PWD=$CURRENT
# mount the gh action directory in the container
docker run \
--env GITHUBLOGIN=$GITHUBLOGIN \
--env GITHUBPASSWORD=$GITHUBPASSWORD \
--mount type=bind,source=${HOME}/.m2,target=/var/maven/.m2 \
--mount type=bind,source=${HOME}/.ssh,target=/home/user/.ssh \
--mount type=bind,source=${HOME}/.gitconfig,target=/home/user/.gitconfig,readonly \
--mount type=bind,source="$(pwd)",target=/usr/src/mymaven \
--mount type=bind,source=${SCRIPT_DIR},target=/usr/local/ci-java-build-action \
--workdir /usr/src/mymaven \
--rm \
--env PUID=`id -u` -e PGID=`id -g` \
--env MAVEN_CONFIG=/var/maven/.m2 \
$MAVEN_IMAGE \
runuser --user user --group user -- mvn -B -e -T 1C -Duser.home=/var/maven --settings /usr/local/ci-java-build-action/ci-settings.xml "$@"
./mvn.sh sonar:sonar \
-D sonar.branch.name=$(git rev-parse --abbrev-ref HEAD|tr / _ ) \
-DskipTests=true \
-Dsonar.language=java \
-Dsonar.report.export.path=sonar-report.json \
-Dsonar.host.url=http://localhost:9000 \
--activate-profiles sonar
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment