Skip to content

Commit 48c3b98

Browse files
committed
ci: build/publish on demand workflow
1 parent 6d1befd commit 48c3b98

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and publish Docker images on demand
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
image_tag:
7+
description: "Image tag"
8+
type: string
9+
required: true
10+
11+
jobs:
12+
multiarch-build:
13+
name: Build and publish ${{ matrix.base }} image with tag ${{ inputs.image_tag }}
14+
strategy:
15+
matrix:
16+
base: [alpine, debian]
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Retrieve version
25+
id: docker-gen_version
26+
run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
27+
28+
- name: Get Docker tags
29+
id: docker_meta
30+
uses: docker/metadata-action@v5
31+
with:
32+
images: |
33+
nginxproxy/docker-gen
34+
tags: |
35+
type=raw,value=${{ inputs.image_tag }},enable=${{ matrix.base == 'alpine' }}
36+
type=raw,value=${{ inputs.image_tag }},suffix=-debian,enable=${{ matrix.base == 'debian' }}
37+
labels: |
38+
org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
39+
org.opencontainers.image.version=${{ steps.docker-gen_version.outputs.VERSION }}
40+
flavor: |
41+
latest=false
42+
43+
- name: Set up QEMU
44+
uses: docker/setup-qemu-action@v3
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Login to DockerHub
50+
uses: docker/login-action@v3
51+
with:
52+
username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
55+
- name: Log in to GitHub Container Registry
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ghcr.io
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Build and push the image
63+
id: docker_build
64+
uses: docker/build-push-action@v6
65+
with:
66+
context: .
67+
build-args: DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
68+
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
69+
file: Dockerfile.${{ matrix.base }}
70+
sbom: true
71+
push: true
72+
provenance: mode=max
73+
tags: ${{ steps.docker_meta.outputs.tags }}
74+
labels: ${{ steps.docker_meta.outputs.labels }}
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
78+
- name: Docker image digest
79+
run: echo ${{ steps.docker_build.outputs.digest }}

0 commit comments

Comments
 (0)