Skip to content

Commit 8f315d9

Browse files
committed
Build images with matrix
1 parent e8bbe05 commit 8f315d9

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

.github/workflows/cd.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ jobs:
1010
permissions:
1111
packages: write
1212
contents: read
13-
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
image:
17+
- name: 'ubuntu:18.04'
18+
suffix: '-ubuntu18.04'
19+
- name: 'ubuntu:20.04'
20+
suffix: '-ubuntu20.04'
21+
- name: 'ubuntu:22.04'
22+
suffix: '-ubuntu22.04'
23+
- name: 'ubuntu:latest'
24+
suffix: ''
1425
steps:
1526
- uses: actions/checkout@v3
1627

@@ -35,6 +46,7 @@ jobs:
3546
uses: docker/build-push-action@v4
3647
with:
3748
push: true
38-
build-args:
39-
- VERSION=${{ steps.set-version.outputs.VERSION }}
40-
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.set-version.outputs.VERSION }}
49+
build-args: |
50+
VERSION=${{ steps.set-version.outputs.VERSION }}
51+
APP_IMAGE=${{ matrix.app_image }}
52+
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.set-version.outputs.VERSION }}${{ matrix.image.suffix }}

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
ARG APP_IMAGE=ubuntu:latest
2+
13
# Build
24
FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS build
35

46
ARG VERSION
57
ARG BUILD_TIME
68

7-
RUN apk update
8-
RUN apk add git
9-
109
WORKDIR /file.d
1110

1211
COPY go.mod go.sum ./
@@ -25,7 +24,7 @@ RUN go build -trimpath \
2524
-o file.d ./cmd/file.d
2625

2726
# Deploy
28-
FROM ubuntu:20.04
27+
FROM $APP_IMAGE
2928

3029
RUN apt update
3130
RUN apt install systemd strace tcpdump traceroute telnet iotop curl jq iputils-ping htop -y

0 commit comments

Comments
 (0)