forked from openMF/message-gateway
-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (116 loc) · 4.15 KB
/
build.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
125
126
127
128
129
130
131
132
133
134
135
136
137
---
name: message-gateway
run-name: message-gatewayd-${{ github.ref_name }}-${{ github.run_number }}
on:
push:
branches:
- main
- develop
- 'release/*'
pull_request:
branches:
- main
- develop
- 'release/*'
schedule:
- cron: '0 0 * * *'
env:
SHOULD_PUBLISH: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref , 'refs/heads/release') }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/[email protected]
with:
fetch-depth: 0
fetch-tags: true
show-progress: false
- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: '16'
- name: Set up Java Version
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
- name: Get Revision and Set Image Tag
run: |
VERSION_TAG=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')
echo "VERSION_TAG=$VERSION_TAG"
IMAGE_TAGS="${VERSION_TAG}.$(date '+%Y.%m.%d').${{ github.run_number }}"
echo "IMAGE_SEMANTIC_HASH=$IMAGE_TAGS"
echo "Tags: $IMAGE_TAGS"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
echo "IMAGE_SEMANTIC_HASH=$IMAGE_TAGS" >> $GITHUB_ENV
echo "IMAGE_TAGS=$IMAGE_TAGS" >> $GITHUB_ENV
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV
- name: Configure Gradle caching
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Gradlew build
run: |
./gradlew bootJar --info --build-cache
- name: Build docker-compose
run: |
MESSAGE_GATEWAY_IMAGE_TAGS=${{ env.IMAGE_TAGS }} docker compose -f docker-compose.yml build
- name: Login to Azure registry
uses: docker/[email protected]
if: ${{ env.SHOULD_PUBLISH == 'true'}}
with:
registry: oaftech.azurecr.io
username: ${{ vars.ACR_PULL_USERNAME }}
password: ${{ secrets.ACR_PULL_PASSWORD }}
- name: Push image to registry
if: ${{ env.SHOULD_PUBLISH == 'true'}}
run: |
docker push oaftech.azurecr.io/oneacrefund/message-gateway:${{ env.IMAGE_TAGS }}
- name: Publish configuration package
uses: actions/[email protected]
if: ${{ env.SHOULD_PUBLISH == 'true'}}
with:
name: message-gateway
path: ${{ github.workspace }}/deployment
sonarcloud:
name: Sonar Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/[email protected]
with:
fetch-depth: 0
fetch-tags: true
show-progress: false
- name: Set up Java Version
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/[email protected]
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Configure Gradle caching
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Gradlew test
run: |
./gradlew :test --info --build-cache
- name: SonarCloud analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --info
- name: Publish Code Coverage Results
uses: actions/[email protected]
with:
name: test-results
path: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml