-
Notifications
You must be signed in to change notification settings - Fork 6
59 lines (50 loc) · 1.56 KB
/
build-and-publish-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
name: Build Docker Image
on:
push:
branches: [main]
tags:
- v[0-9]+.[0-9]+.[0-9]+
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-24.04
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "temurin"
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/gamma
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=ref,event=branch
type=ref,event=pr
- name: Build Docker image
run: ./gradlew bootBuildImage
- name: Push docker image
run: |
for tag in $(jq -r '.tags | join(" ")' <<< "${{ steps.meta.outputs.metadata }}"); do
docker image tag app:latest $tag
done
docker image push --all-tags ghcr.io/${{ github.repository_owner }}/gamma