diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 15e81a0df..db8129a94 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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 @@ -29,12 +32,19 @@ jobs: run: | VERSION=${GITHUB_REF/refs\/tags\//} echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + + # if app_image == '' then '' else '-' + 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 }} diff --git a/Dockerfile b/Dockerfile index a59e92471..dc25eb352 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +ARG APP_IMAGE=ubuntu:latest + # Build FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS build @@ -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