-
Notifications
You must be signed in to change notification settings - Fork 29
124 lines (115 loc) · 4.05 KB
/
sonarquest-ci.yml
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# This is the CI Action for SonarQuest to automatically build Docker images on master push and release.
name: SonarQuest-CI
# Controls when the action will run.
on:
push:
release:
types: [ released, prereleased, edited ]
workflow_dispatch:
jobs:
backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build backend with Maven
run: mvn -f ./sonarQuest-backend/pom.xml --batch-mode --update-snapshots verify
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: ${{ github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/master') }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image - Release
uses: docker/build-push-action@v2
if: ${{ github.event_name == 'release' }}
with:
context: ./sonarQuest-backend
push: true
tags: |
ghcr.io/viadee/sonarquest-backend:latest
ghcr.io/viadee/sonarquest-backend:${{ github.event.release.tag_name }}
- name: Build and push Docker image - Nightly
uses: docker/build-push-action@v2
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
with:
context: ./sonarQuest-backend
push: true
tags: ghcr.io/viadee/sonarquest-backend:nightly
sonar-analysis-backend:
name: SonarCloud Analysis
runs-on: ubuntu-latest
strategy:
matrix:
include:
- app: sonarquest-backend
working-directory: ./backend
sonar-project-key: viadee_sonarQuest
sonar-organization: viadee
sonar-host-url: https://sonarcloud.io
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -f ./sonarQuest-backend/pom.xml -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.projectKey=${{ matrix.sonar-project-key }} \
-Dsonar.organization=${{ matrix.sonar-organization }}
frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup node.js
uses: actions/setup-node@v1
with:
node-version: '10.9.0'
- name: Install dependencies
run: |
cd sonarQuest-frontend
npm i
- name: Build Angular app
run: |
cd sonarQuest-frontend
npm run build:prod
- name: Test
run: |
cd sonarQuest-frontend
npm test
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
if: ${{ github.event_name == 'release' || (github.event_name == 'push' && github.ref == 'refs/heads/master') }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image - Release
uses: docker/build-push-action@v2
if: ${{ github.event_name == 'release' }}
with:
context: ./sonarQuest-frontend
push: true
tags: |
ghcr.io/viadee/sonarquest-frontend:latest
ghcr.io/viadee/sonarquest-frontend:${{ github.event.release.tag_name }}
- name: Build and push Docker image - Nightly
uses: docker/build-push-action@v2
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
with:
context: ./sonarQuest-frontend
push: true
tags: ghcr.io/viadee/sonarquest-frontend:nightly