generated from making/opinionated-spring-boot-app
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (76 loc) · 2.22 KB
/
ci.yaml
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: CI
on:
push:
branches:
- main
paths:
- src/**
- ui/**
- pom.xml
- .github/workflows/*
pull_request:
branches:
- main
paths:
- src/**
- ui/**
- pom.xml
- .github/workflows/*
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Install GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
cache: 'maven'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Unit Tests
run: ./mvnw -V --no-transfer-progress clean test
- name: Executable Jar
run: |
set -e
./mvnw -V --no-transfer-progress package -DskipTests
java -jar target/*.jar --server.port=8080 &
.github/workflows/wait.sh
curl --fail --show-error --silent http://localhost:8080/actuator/health
pkill -KILL java
- name: Import Secrets
if: github.ref == 'refs/heads/main'
id: secrets
uses: hashicorp/[email protected]
with:
exportToken: true
exportEnv: true
method: jwt
url: ${{ secrets.VAULT_ADDR }}
role: cicd
secrets: |
kv/data/cicd/github api_token | GITHUB_API_TOKEN ;
kv/data/cicd/fly api_token | FLY_API_TOKEN
- name: Docker Login
if: github.ref == 'refs/heads/main'
run: docker login ghcr.io -u ${GITHUB_REPOSITORY_OWNER} -p ${GITHUB_API_TOKEN}
- name: Build Docker Image (JVM)
if: github.ref == 'refs/heads/main'
run: |
set -e
./mvnw -V --no-transfer-progress spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=ghcr.io/${GITHUB_REPOSITORY}:jvm
- name: Build Docker Image (Native)
if: github.ref == 'refs/heads/main'
run: |
set -e
./mvnw -V --no-transfer-progress spring-boot:build-image -Pnative -DskipTests -Dspring-boot.build-image.imageName=ghcr.io/${GITHUB_REPOSITORY}:native
- name: Docker Push
if: github.ref == 'refs/heads/main'
run: |
set -e
docker push ghcr.io/${GITHUB_REPOSITORY}:jvm
docker push ghcr.io/${GITHUB_REPOSITORY}:native