Skip to content

Build and Push Integration Containers #10

Build and Push Integration Containers

Build and Push Integration Containers #10

name: Build and Push Integration Containers
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'integration/**'
jobs:
generate-matrix:
runs-on: ubuntu-latest
permissions: {}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
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],
platform: ($parts[1] | split("-")[0]),
platform_version: ($parts[1] | split("-")[1] // ""),
}' | jq -s .)
echo "matrix=$(echo "$MATRIX" | jq -c .)" >> $GITHUB_OUTPUT
image:
needs: generate-matrix
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Determine Architectures
id: arch
run: |
CONTAINER="${{ matrix.platform }}-${{ matrix.platform_version }}"
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: Get cache config
id: gha_cache
uses: actions/github-script@v7
with:
script: |
core.setOutput('cache_url', process.env.ACTIONS_CACHE_URL || '');
core.setOutput('runtime_token', process.env.ACTIONS_RUNTIME_TOKEN || '');
- 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.platform }}-${{ matrix.platform_version }}
push: true
platforms: ${{ steps.arch.outputs.archs }}
build-args: |
SCCACHE_GHA_ENABLED=on
secrets: |
ACTIONS_CACHE_URL=${{ steps.gha_cache.outputs.cache_url }}
ACTIONS_RUNTIME_TOKEN=${{ steps.gha_cache.outputs.runtime_token }}
tags: |
ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }}:latest
ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }}:${{ 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,ref=ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }}:cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/gelpkg-${{ matrix.stage }}-${{ matrix.platform }}-${{ matrix.platform_version }}:cache