-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (45 loc) · 1.42 KB
/
build-and-deploy.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
on:
push:
branches:
- master
env:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "-B -e -fae -DinstallAtEnd=true -DdeployAtEnd=true"
jobs:
maven:
runs-on: ubuntu-latest
container:
image: maven:3.9.6-eclipse-temurin-22-alpine
steps:
- uses: actions/checkout@master
- uses: actions/cache@master
with:
path: .m2/repository
key: ${{ hashFiles('**/pom.xml') }}
- run: mvn ${{ env.MAVEN_CLI_OPTS }} clean install
- uses: actions/upload-artifact@master
with:
name: app-jar
path: target/*.jar
docker:
runs-on: ubuntu-latest
needs: maven
container:
image: docker:latest
steps:
- uses: actions/checkout@master
- uses: actions/download-artifact@master
with:
name: app-jar
path: target
- uses: docker/login-action@master
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
cp src/main/docker/Dockerfile .
cp target/*.jar .
docker context create builder-context
docker buildx create --driver docker-container --use builder-context
docker buildx build --platform=linux/arm64,linux/amd64 -t ghcr.io/${{ github.repository }}:${{ github.sha }} -t ghcr.io/${{ github.repository }}:latest --push .