@@ -33,42 +33,29 @@ jobs:
3333 fetch-depth : 0
3434
3535 - name : Retrieve version
36- run : echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV
36+ id : docker-gen_version
37+ run : echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
3738
38- - name : Get Docker tags for Alpine based image
39- if : ${{ matrix.base == 'alpine' }}
40- id : docker_meta_alpine
39+ - name : Get Docker tags
40+ id : docker_meta
4141 uses : docker/metadata-action@v4
4242 with :
4343 images : |
4444 ghcr.io/nginx-proxy/docker-gen
4545 nginxproxy/docker-gen
4646 jwilder/docker-gen
4747 tags : |
48- type=semver,pattern={{version}}
49- type=semver,pattern={{major}}.{{minor}}
50- type=raw,value=latest,enable={{is_default_branch}}
48+ type=semver,pattern={{version}},enable=${{ matrix.base == 'alpine' }}
49+ type=semver,pattern={{major}}.{{minor}},enable=${{ matrix.base == 'alpine' }}
50+ type=semver,suffix=-debian,pattern={{version}},enable=${{ matrix.base == 'debian' }}
51+ type=semver,suffix=-debian,pattern={{major}}.{{minor}},enable=${{ matrix.base == 'debian' }}
52+ type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'alpine' }}
53+ type=raw,value=debian,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'debian' }}
5154 labels : |
5255 org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
53- org.opencontainers.image.version=${{ env.GIT_DESCRIBE }}
54-
55- - name : Get Docker tags for Debian based image
56- if : ${{ matrix.base == 'debian' }}
57- id : docker_meta_debian
58- uses : docker/metadata-action@v4
59- with :
60- images : |
61- ghcr.io/nginx-proxy/docker-gen
62- nginxproxy/docker-gen
63- jwilder/docker-gen
64- tags : |
65- type=semver,suffix=-debian,pattern={{version}}
66- type=semver,suffix=-debian,pattern={{major}}.{{minor}}
67- type=raw,value=debian,enable={{is_default_branch}}
68- labels : |
69- org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
70- org.opencontainers.image.version=${{ env.GIT_DESCRIBE }}
71- flavor : latest=false
56+ org.opencontainers.image.version=${{ steps.docker-gen_version.outputs.VERSION }}
57+ flavor : |
58+ latest=false
7259
7360 - name : Set up QEMU
7461 uses : docker/setup-qemu-action@v2
@@ -89,35 +76,19 @@ jobs:
8976 username : ${{ github.actor }}
9077 password : ${{ secrets.GITHUB_TOKEN }}
9178
92- - name : Build and push the Alpine based image
93- if : ${{ matrix.base == 'alpine' }}
94- id : docker_build_alpine
95- uses : docker/build-push-action@v4
96- with :
97- context : .
98- build-args : DOCKER_GEN_VERSION=${{ env.GIT_DESCRIBE }}
99- platforms : linux/amd64,linux/arm64,linux/arm/v7
100- push : true
101- tags : ${{ steps.docker_meta_alpine.outputs.tags }}
102- labels : ${{ steps.docker_meta_alpine.outputs.labels }}
103-
104- - name : Build and push the Debian based image
105- if : ${{ matrix.base == 'debian' }}
106- id : docker_build_debian
79+ - name : Build and push the image
80+ id : docker_build
10781 uses : docker/build-push-action@v4
10882 with :
10983 context : .
110- build-args : DOCKER_GEN_VERSION=${{ env.GIT_DESCRIBE }}
111- file : Dockerfile.debian
112- platforms : linux/amd64,linux/arm64,linux/arm/v7
84+ build-args : DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
85+ platforms : linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
86+ file : Dockerfile.${{ matrix.base }}
11387 push : true
114- tags : ${{ steps.docker_meta_debian.outputs.tags }}
115- labels : ${{ steps.docker_meta_debian.outputs.labels }}
116-
117- - name : Alpine based image digest
118- if : ${{ matrix.base == 'alpine' }}
119- run : echo ${{ steps.docker_build_alpine.outputs.digest }}
88+ tags : ${{ steps.docker_meta.outputs.tags }}
89+ labels : ${{ steps.docker_meta.outputs.labels }}
90+ cache-from : type=gha
91+ cache-to : type=gha,mode=max
12092
121- - name : Debian based image digest
122- if : ${{ matrix.base == 'debian' }}
123- run : echo ${{ steps.docker_build_debian.outputs.digest }}
93+ - name : Docker image digest
94+ run : echo ${{ steps.docker_build.outputs.digest }}
0 commit comments