-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (53 loc) · 1.54 KB
/
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
name: Java CI with Maven
on:
push:
branches: ["another-feature"]
pull_request:
branches: ["another-feature"]
permissions:
contents: read
checks: write
id-token: write
jobs:
test:
name: Build and Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Check out code
- name: Setup Maven Action
uses: s4u/setup-maven-action@v1.11.0
with:
java-version: 17
- name: Run tests
run: mvn test
- name: Generate report
uses: mikepenz/action-junit-report@v4
with:
report-path: target/surefire-reports
generate-html-report: true
build-and-push-docker-image:
needs: test
runs-on: ubuntu-latest
steps:
- name: Setup Maven Action
uses: s4u/setup-maven-action@v1.11.0
with:
java-version: 17
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build image
run: mvn spring-boot:build-image -Ddockerfile=Dockerfile.layers -DskipTests
- name: Get project version
run: |
version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' exec:exec)
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Set image name
run: echo "IMAGE_NAME=wallet:${VERSION}" >> $GITHUB_ENV
- name: print IMAGE_NAME
run: echo ${IMAGE_NAME}
- name: Push image
run: docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}