Skip to content

add go matrix to build images for multiple go versions #2

add go matrix to build images for multiple go versions

add go matrix to build images for multiple go versions #2

name: Build and Push Builder Image
on:
push:
branches:
- main
- master
- feat/fips-image-and-workflow # for testing purposes
jobs:
build-and-push:
name: Build and Push Builder Image
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.22.9, 1.23.2, 1.23.3] # Create a matrix of Go versions to build images for
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set version
id: set_version
run: |
VERSION="${{ github.run_number }}-$(date +'%Y%m%d%H%M%S')"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: build/Dockerfile
build-args: |
GO_VERSION=${{ matrix.go-version }}
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.VERSION }}-go${{ matrix.go-version }}
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest-go${{ matrix.go-version }}