Skip to content

Commit

Permalink
Build images with matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimalekseev committed Aug 13, 2023
1 parent e8bbe05 commit 7e60444
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ jobs:
permissions:
packages: write
contents: read

strategy:
fail-fast: false
matrix:
app_image: [ '', 'ubuntu:20.04', 'ubuntu:22.04' ]
steps:
- uses: actions/checkout@v3

Expand All @@ -29,12 +32,19 @@ jobs:
run: |
VERSION=${GITHUB_REF/refs\/tags\//}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
# if app_image == '' then '' else '-<app_image>'
IMAGE_TAG_SUFFIX=$([ ${{ matrix.app_image }} == '' ] && echo '' || echo -${{ matrix.app_image }})
# replace : with ''
IMAGE_TAG_SUFFIX=${IMAGE_TAG_SUFFIX/:/}
echo "IMAGE_TAG_SUFFIX=${IMAGE_TAG_SUFFIX}" >> $GITHUB_OUTPUT
- name: Build and push
id: docker-build
uses: docker/build-push-action@v4
with:
push: true
build-args:
- VERSION=${{ steps.set-version.outputs.VERSION }}
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.set-version.outputs.VERSION }}
build-args: |
VERSION=${{ steps.set-version.outputs.VERSION }}
APP_IMAGE=${{ matrix.app_image }}
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.set-version.outputs.VERSION }}${{ steps.set-version.outputs.IMAGE_TAG_SUFFIX }}
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG APP_IMAGE=ubuntu:latest

# Build
FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS build

Expand Down Expand Up @@ -25,7 +27,7 @@ RUN go build -trimpath \
-o file.d ./cmd/file.d

# Deploy
FROM ubuntu:20.04
FROM $APP_IMAGE

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

0 comments on commit 7e60444

Please sign in to comment.