Skip to content

Build and Push Integration Containers #1

Build and Push Integration Containers

Build and Push Integration Containers #1

name: Build and Push Integration Containers
on:
workflow_dispatch:
push:
branches:
- main
jobs:
generate-matrix:
runs-on: ubuntu-latest
permissions: {}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Generate matrix JSON
id: set-matrix
run: |
MATRIX=$(for stage in build test testpublished upload; do
subdir="integration/linux/$stage"
find "$subdir" -maxdepth 1 -mindepth 1 -type d ! -name "_bootstrap" -printf "$stage\t%P\n"
done | jq -R '
split("\t") as $parts |
{
stage: $parts[0],
container: $parts[1],
platform: ($parts[1] | split("-")[0]),
platform_version: ($parts[1] | split("-")[1] // ""),
}' | jq -s .)
echo "matrix=$(echo "$MATRIX" | jq -c .)" >> $GITHUB_OUTPUT
build-containers:
needs: generate-matrix
runs-on: ubuntu-latest
permissions: {}
strategy:
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Determine Architectures
id: arch
run: |
CONTAINER="${{ matrix.container }}"
if [[ "$CONTAINER" == *aarch64* ]]; then
echo "archs=linux/arm64" >> $GITHUB_OUTPUT
elif [[ "$CONTAINER" == *x86_64* ]]; then
echo "archs=linux/amd64" >> $GITHUB_OUTPUT
else
echo "archs=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
fi
- name: Set build date
id: meta
run: echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # 3.6.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # 3.10.0
with:
cache-binary: false
- name: Log in to GitHub Container Registry
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # 3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Image
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # 6.15.0
with:
context: integration/linux/${{ matrix.stage }}/${{ matrix.container }}
push: true
platforms: ${{ steps.arch.outputs.archs }}
tags: |
ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.container }}:latest
ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.container }}:${{ steps.meta.outputs.date }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ steps.meta.outputs.date }}
cache-from: type=registry,dest=ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.container }}:cache
cache-to: type=registry,dest=ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.container }}:cache