-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (65 loc) · 1.96 KB
/
maven.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
name: Java CI with Maven
on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Maven, package as OCI Image with CNB
env:
DOCKER_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: |
mvn spring-boot:build-image \
-Dspring-boot.build-image.imageName=${DOCKER_IMAGE}:${{ github.sha }} \
-Dspring-boot.build-image.publish=false
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Tag latest
if: github.ref == 'refs/heads/main'
env:
DOCKER_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: |
docker tag ${DOCKER_IMAGE}:${{ github.sha }} ${DOCKER_IMAGE}:latest
docker push ${DOCKER_IMAGE}:latest
- name: Chart | Push
uses: appany/[email protected]
with:
name: mongodb-probe-chart
repository: ${DOCKER_IMAGE}-chart
tag: 0.0.1
path: chart/mongodb-probe # Default charts/{name}
registry: ${{ env.REGISTRY }}
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Package
path: |
target/*.jar