-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (88 loc) · 3.43 KB
/
build-push-container-images.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
name: Build and Push Container Images
on:
push:
branches:
- master
permissions:
contents: read
packages: write
env:
JAVA_VERSION: "21"
DISTRIBUTION: "openjdk"
CONTAINER_REGISTRY: "ghcr.io"
CONTAINER_GROUP: "cloudeko/services"
jobs:
build-image:
name: Build Docker Image
environment: development
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.DISTRIBUTION }}
cache: maven
- name: Get Short SHA
id: short_sha
run: echo "short_sha=$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_OUTPUT
- name: Set Maven Version
run: |
mvn versions:set -DnewVersion=${{ steps.short_sha.outputs.short_sha }}
- name: Set IMAGE_NAME env variable
run: |
MODULE_NAME=zenei
TEMP_NAME=$(echo "${MODULE_NAME}")
IMAGE_NAME=$(echo "$TEMP_NAME" | sed -r 's/([a-z])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]')
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.CONTAINER_REGISTRY }} -u ${{ github.actor }} --password-stdin
- name: Build and push native image
run: |
mvn clean install -DskipTests \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.push=true \
-Dquarkus.container-image.registry=${{ env.CONTAINER_REGISTRY }} \
-Dquarkus.container-image.group=${{ env.CONTAINER_GROUP }} \
-Dquarkus.container-image.name=${{ env.IMAGE_NAME }} \
-Dquarkus.container-image.tag=${{ steps.short_sha.outputs.short_sha }}
build-native-image:
name: Build Native Docker Image
environment: development
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.DISTRIBUTION }}
cache: maven
- name: Get Short SHA
id: short_sha
run: echo "short_sha=$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_OUTPUT
- name: Set Maven Version
run: |
mvn versions:set -DnewVersion=${{ steps.short_sha.outputs.short_sha }}
- name: Set IMAGE_NAME env variable
run: |
MODULE_NAME=zenei
TEMP_NAME=$(echo "${MODULE_NAME}")
IMAGE_NAME=$(echo "$TEMP_NAME" | sed -r 's/([a-z])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]')
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.CONTAINER_REGISTRY }} -u ${{ github.actor }} --password-stdin
- name: Build and push native image
run: |
mvn clean install -DskipTests \
-Dnative \
-Dquarkus.native.container-build=true \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.push=true \
-Dquarkus.container-image.registry=${{ env.CONTAINER_REGISTRY }} \
-Dquarkus.container-image.group=${{ env.CONTAINER_GROUP }}/native \
-Dquarkus.container-image.name=${{ env.IMAGE_NAME }} \
-Dquarkus.container-image.tag=${{ steps.short_sha.outputs.short_sha }}