-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (47 loc) · 2.12 KB
/
Copy pathci.yml
File metadata and controls
55 lines (47 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
## A simple example to use Github Actions for Java CI
## This produces a simple jar artefact are store in the github maven repository
# We build the project using maven.
# The credential ae set in a specific settings.xml using env variables
# The ENV variables are stored as Github Secrets
#
# The secrets are set in CLI with https://www.npmjs.com/package/gh-create-update-secret
#
# ghrepo=`git remote -v|grep fetch|sed 's/.*:\(.*\).git/\1/'`
# export GH_PAT=$GITHUB_PASSWORD
# gh-create-update-secret --secret GITHUBLOGIN --value $GITHUB_LOGIN --repo $ghrepo
# gh-create-update-secret --secret GITHUBPASSWORD --value $GITHUB_PASSWORD --repo $ghrepo
# gh-create-update-secret --secret DOCKER_USERNAME --value $DOCKER_USERNAME --repo $ghrepo
# gh-create-update-secret --secret DOCKER_PASSWORD --value $DOCKER_PASSWORD --repo $ghrepo
# gh-create-update-secret --secret SONAR_TOKEN --value $SONAR_TOKEN --repo $ghrepo
name: Java CI
# on every push
on: [push]
env:
GITHUBLOGIN: ${{secrets.GITHUBLOGIN}}
GITHUBPASSWORD: ${{secrets.GITHUBPASSWORD}}
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
jobs:
# This job build, test, package and deploy the artefact
maven-build:
# The tags on the runner
runs-on: [self-hosted, Linux]
steps:
#we get the content of the repository
- uses: actions/checkout@v2
# 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: Build and test with Maven in docker
run: ./mvn.sh clean verify
# This job runs a sonarqube analysis on the hosted runner
# only on develop branch
maven-sonar:
runs-on: [self-hosted, Linux]
needs: maven-build
# Develop branch only
# if: github.ref == 'refs/heads/develop'
steps:
- name: Launch a sonar analysis
run: ./mvn.sh -D sonar.branch.name=${GITHUB_REF#refs/heads/} --activate-profiles sonar sonar:sonar && mvn --activate-profiles sonar -pl . sonar-quality-gate:check