generated from finos-labs/project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 100
80 lines (69 loc) · 2.97 KB
/
docker-publish-calm-hub.yml
File metadata and controls
80 lines (69 loc) · 2.97 KB
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
name: Docker Publish Calm Hub
permissions:
contents: read
on:
# Only manual trigger from GitHub UI
workflow_dispatch:
inputs:
tag:
description: 'Image tag (default: latest)'
required: false
default: 'latest'
jobs:
build-and-push:
name: Build and Push Multi-Arch Docker Image
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
# Step 2: Set up JDK
- name: Set up JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: 'temurin'
java-version: '21'
# Step 3: Cache Maven Dependencies
- name: Cache Maven Dependencies
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('calm-hub/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-
# Step 4: Build the application with Maven
- name: Build with Maven
working-directory: calm-hub
run: mvn -P integration clean package -Ddependency-check.skip=true
# Step 5: Set up Docker Buildx for multi-architecture builds
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
# Step 6: Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Step 7: Extract metadata for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/calm-hub
tags: |
type=raw,value=${{ github.event.inputs.tag || 'latest' }}
type=sha,format=short
type=ref,event=branch
type=ref,event=tag
# Step 8: Build and push Docker image
- name: Build and push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
with:
context: calm-hub
file: calm-hub/src/main/docker/Dockerfile.jvm
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max