forked from jhipster/jhipster-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (58 loc) · 1.84 KB
/
publish-jvm-docker-image.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
name: Build and publish JVM-based images
on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
branches:
- main
jobs:
build_jvm_docker_image:
name: Build and publish the JVM-based Docker image
runs-on: ubuntu-22.04
env:
DOCKER_IMAGE_NAME: '${{ github.repository_owner }}/jhipster-lite'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
- name: Login to Docker Registry
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
uses: docker/[email protected]
id: login-hub
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Restore cache for local Maven repository
id: cache
uses: actions/cache@v4
with:
path: maven-repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: inject maven-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"maven-repository": "/root/.m2",
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build the JVM-based Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max