Use local builg tagging #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: buildah-build-builder | |
on: | |
schedule: | |
- cron: "19 19 * * 0" # 19:19 UTC every Sunday | |
push: | |
paths: | |
- .github/workflows/buildah-build-builder.yml # Self-trigger | |
- containers/esmini-builder/Dockerfile | |
workflow_dispatch: | |
inputs: | |
esmini_version: | |
description: ESMINI_VERSION | |
type: string | |
required: true | |
default: v2.45.1 | |
env: | |
REGISTRY: ghcr.io/bounverif | |
IMAGE_NAME: esmini | |
ESMINI_VERSION: v2.45.1 | |
# CONTAINERS_ROOT: /home/runner/.local/share/containers | |
# TMPDIR: /home/runner/.local/share/containers/tmp | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
buildah-build: | |
name: Build container images | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-24.04, ubuntu-24.04-arm] | |
runs-on: ${{ matrix.os }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }} | |
cancel-in-progress: true | |
steps: | |
- name: Install container tools | |
run: sudo apt-get install podman buildah jq | |
# - name: Maximize build space | |
# uses: easimon/maximize-build-space@v10 | |
# with: | |
# root-reserve-mb: 2048 # Reserve disk space for repository | |
# remove-dotnet: "true" | |
# remove-android: "true" | |
# remove-haskell: "true" | |
# remove-codeql: "true" | |
# remove-docker-images: "true" | |
# build-mount-path: ${{ env.CONTAINERS_ROOT }} # The remaining space only for container build | |
# - run: mkdir -p $TMPDIR | |
- name: Set platform tag | |
run: | | |
platform=$(podman info --format='{{.Version.OsArch}}' | sed 's/\//-/g') | |
echo "PLATFORM=${platform}" >> $GITHUB_ENV | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the GitHub Container registry | |
uses: redhat-actions/podman-login@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build builder container image | |
id: build-builder | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
context: ./containers | |
image: localhost/esmini | |
tags: ${{ env.ESMINI_VERSION }}-builder | |
layers: true | |
oci: true | |
build-args: | | |
ESMINI_VERSION=${{ env.ESMINI_VERSION }} | |
extra-args: | | |
--target esmini-builder | |
containerfiles: | | |
./containers/esmini-builder/Dockerfile | |
- name: Build devel container image | |
id: build-devel | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
context: ./containers | |
image: localhost/esmini | |
tags: ${{ env.ESMINI_VERSION }}-devel | |
layers: true | |
oci: true | |
build-args: | | |
ESMINI_VERSION=${{ env.ESMINI_VERSION }} | |
extra-args: | | |
--target esmini-devel | |
containerfiles: | | |
./containers/esmini-builder/Dockerfile | |
- name: Push to GitHub Container Repository | |
# if: github.ref == 'refs/heads/main' | |
if: github.ref == 'refs/heads/multiarch-image' | |
id: push-builder-ghcr | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ steps.build-builder.outputs.image }} | |
digestfile: ${{ runner.temp }}/digest-esmini-builder-${{ env.PLATFORM }} | |
- name: Push to GitHub Container Repository | |
# if: github.ref == 'refs/heads/main' | |
if: github.ref == 'refs/heads/multiarch-image' | |
id: push-devel-ghcr | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ steps.build-devel.outputs.image }} | |
digestfile: ${{ runner.temp }}/digest-esmini-devel-${{ env.PLATFORM }} | |
buildah-merge: | |
name: Merge container images | |
runs-on: ubuntu-24.04 | |
needs: buildah-build | |
# if: github.ref == 'refs/heads/main' | |
if: github.ref == 'refs/heads/multiarch-image' | |
steps: | |
# - run: mkdir -p $TMPDIR | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ runner.temp }}/digests | |
pattern: digest-* | |
merge-multiple: true | |
- name: Log in to the GitHub Container registry | |
uses: redhat-actions/podman-login@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set current date as the version | |
run: echo "ESMINI_LATEST_VERSION=$(curl -sL "https://api.github.com/repos/esmini/esmini/releases/latest" | jq -r '.tag_name')" >> $GITHUB_ENV | |
- name: Create manifest list for esmini-builder | |
run: | | |
REPO=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
buildah manifest create $REPO | |
for digest in ${{ runner.temp }}/digests/digest-esmini-builder-*; do | |
echo "Adding $(cat $digest)" | |
buildah manifest add $REPO $REPO@$(cat $digest) | |
done | |
buildah manifest push --all $REPO docker://$REPO:${{ env.ESMINI_VERSION }}-builder-multiarch-image | |
if [ "${{ env.ESMINI_VERSION }}" == "${{ env.ESMINI_LATEST_VERSION }}" ]; then | |
buildah manifest push --all $REPO docker://$REPO:latest-builder-multiarch-image | |
fi |