-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (126 loc) · 4.36 KB
/
docker-publish-on-tag.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Docker Publish & GitHub Release
on:
push:
tags:
- '**'
env:
IMAGE_NAME: ghusta/fakesmtp
ENABLE_QEMU: 1
jobs:
docker-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- # Add support for more platforms with QEMU (optional)
# https://github.com/marketplace/actions/docker-setup-qemu
name: Set up QEMU
if: ${{ env.ENABLE_QEMU == '1' }}
uses: docker/setup-qemu-action@v3
# https://github.com/marketplace/actions/docker-setup-buildx
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
# https://github.com/marketplace/actions/docker-login
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/marketplace/actions/docker-metadata-action
- name: Extract Docker metadata / suffix jre21
id: meta-jre21
uses: docker/metadata-action@v5
env:
TAG_SUFFIX: '-jre21'
with:
images: ${{ env.IMAGE_NAME }}
flavor: |
latest=true
tags: |
# semver-only tags
type=semver,pattern={{version}}
type=semver,pattern={{version}},suffix=${{ env.TAG_SUFFIX }}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}},suffix=${{ env.TAG_SUFFIX }}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push Docker images (multi-architecture) / jre21
id: build-and-push-jre21
uses: docker/build-push-action@v6
with:
context: .
build-args: |
JAVA_IMAGE_TAG=21-jre
platforms: |
linux/amd64
linux/arm64/v8
push: true
provenance: false
tags: ${{ steps.meta-jre21.outputs.tags }}
labels: ${{ steps.meta-jre21.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract Docker metadata / suffix jre17
id: meta-jre17
uses: docker/metadata-action@v5
env:
TAG_SUFFIX: '-jre17'
with:
images: ${{ env.IMAGE_NAME }}
flavor: |
latest=false
suffix=${{ env.TAG_SUFFIX }}
tags: |
# semver-only tags
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push Docker images (multi-architecture) / jre17
id: build-and-push-jre17
uses: docker/build-push-action@v6
with:
context: .
build-args: |
JAVA_IMAGE_TAG=17-jre
platforms: |
linux/amd64
linux/arm64/v8
linux/arm/v7
push: true
provenance: false
tags: ${{ steps.meta-jre17.outputs.tags }}
labels: ${{ steps.meta-jre17.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
create-github-release:
needs: [ docker-publish ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# https://github.com/actions/create-release
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
body: |
Docker image published:
![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/${{ env.IMAGE_NAME }}/${{ github.ref_name }}?logo=docker)
Pull it with:
```shell
docker pull ${{ env.IMAGE_NAME }}:${{ github.ref_name }}
```
Alternatively, you can pull an image with a given JRE:
```shell
docker pull ${{ env.IMAGE_NAME }}:${{ github.ref_name }}-jre21
```
```shell
docker pull ${{ env.IMAGE_NAME }}:${{ github.ref_name }}-jre17
```
draft: false
prerelease: false