Skip to content

buildah-build-devel #59

buildah-build-devel

buildah-build-devel #59

name: buildah-build-devel
on:
schedule:
- cron: "19 19 * * 0" # 19:19 UTC every Sunday
push:
paths:
- containers/bazalt-devel/**
- .github/workflows/buildah-build-devel.yml # Self-trigger
workflow_dispatch:
env:
REGISTRY: ghcr.io/bounverif
IMAGE_NAME: bazalt
PODMAN_ARCH: amd64
PLATFORM: linux-amd64
BAZALT_VERSION: latest
BAZALT_LATEST_VERSION: latest
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: Prepare environment variables
run: |
echo "PODMAN_ARCH=$(podman info --format='{{.Host.Arch}}')" >> $GITHUB_ENV
echo "PLATFORM=$(podman info --format='{{.Version.OsArch}}' | sed 's/\//-/g')" >> $GITHUB_ENV
echo "BAZALT_VERSION=$(date +'%Y%m%d')" >> $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: bazalt
tags: |
${{ env.BAZALT_VERSION }}-builder
${{ env.BAZALT_VERSION }}-builder-${{ env.PODMAN_ARCH }}
layers: true
oci: true
build-args: |
BAZALT_VERSION=${{ env.BAZALT_VERSION }}
BAZALT_IMAGE_REGISTRY_REMOTE=${{ env.REGISTRY }}
extra-args: |
--target bazalt-builder
containerfiles: |
./containers/bazalt-devel/Dockerfile
- name: Build devel container image
id: build-devel
uses: redhat-actions/buildah-build@v2
with:
context: ./containers
image: bazalt
tags: ${{ env.BAZALT_VERSION }}-devel ${{ env.BAZALT_VERSION }}-devel-${{ env.PODMAN_ARCH }}
layers: true
oci: true
build-args: |
BAZALT_VERSION=${{ env.BAZALT_VERSION }}
BAZALT_IMAGE_REGISTRY_REMOTE=${{ env.REGISTRY }}
extra-args: |
--target bazalt-devel
containerfiles: |
./containers/bazalt-devel/Dockerfile
- name: Build runtime container image
id: build-runtime
uses: redhat-actions/buildah-build@v2
with:
context: ./containers
image: bazalt
tags: ${{ env.BAZALT_VERSION }}-runtime ${{ env.BAZALT_VERSION }}-runtime-${{ env.PODMAN_ARCH }}
layers: true
oci: true
build-args: |
BAZALT_VERSION=${{ env.BAZALT_VERSION }}
BAZALT_IMAGE_REGISTRY_REMOTE=${{ env.REGISTRY }}
extra-args: |
--target bazalt-runtime
containerfiles: |
./containers/bazalt-devel/Dockerfile
- name: Push to GitHub Container Repository
if: github.ref == 'refs/heads/main'
id: push-builder-ghcr
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ env.REGISTRY }}
image: ${{ steps.build-builder.outputs.image }}
tags: ${{ env.BAZALT_VERSION }}-builder-${{ env.PODMAN_ARCH }}
digestfile: ${{ runner.temp }}/digest-bazalt-builder-${{ env.BAZALT_VERSION }}-${{ env.PLATFORM }}
- name: Push to GitHub Container Repository
if: github.ref == 'refs/heads/main'
id: push-devel-ghcr
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ env.REGISTRY }}
image: ${{ steps.build-devel.outputs.image }}
tags: ${{ env.BAZALT_VERSION }}-devel-${{ env.PODMAN_ARCH }}
digestfile: ${{ runner.temp }}/digest-bazalt-devel-${{ env.BAZALT_VERSION }}-${{ env.PLATFORM }}
- name: Push to GitHub Container Repository
if: github.ref == 'refs/heads/main'
id: push-runtime-ghcr
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ env.REGISTRY }}
image: ${{ steps.build-devel.outputs.image }}
tags: ${{ env.BAZALT_VERSION }}-runtime-${{ env.PODMAN_ARCH }}
digestfile: ${{ runner.temp }}/digest-bazalt-runtime-${{ env.BAZALT_VERSION }}-${{ env.PLATFORM }}
- name: Upload digests
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: digest-bazalt-${{ env.BAZALT_VERSION }}-${{ env.PLATFORM }}
path: ${{ runner.temp }}/digest-*
if-no-files-found: error
retention-days: 1
compression-level: 0 # no compression
buildah-merge:
name: Merge container images
runs-on: ubuntu-24.04
needs: buildah-build
if: github.ref == 'refs/heads/main' && always()
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: Prepare environment variables
run: |
if [ "${{ env.BAZALT_VERSION }}" == "latest" ]; then
echo "BAZALT_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV
fi
echo "BAZALT_LATEST_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Create and push manifest list for bazalt-builder
run: |
MANIFEST=bazalt-builder
FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
buildah manifest create $MANIFEST
for digest in ${{ runner.temp }}/digests/digest-bazalt-builder-*; do
echo "Adding $(cat $digest)"
buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest)
done
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.BAZALT_VERSION }}-builder
if [ "${{ env.BAZALT_VERSION }}" == "${{ env.BAZALT_LATEST_VERSION }}" ]; then
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-builder
fi
- name: Create and push manifest list for bazalt-devel
run: |
MANIFEST=bazalt-devel
FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
buildah manifest create $MANIFEST
for digest in ${{ runner.temp }}/digests/digest-bazalt-devel-*; do
echo "Adding $(cat $digest)"
buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest)
done
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.BAZALT_VERSION }}-devel
if [ "${{ env.BAZALT_VERSION }}" == "${{ env.BAZALT_LATEST_VERSION }}" ]; then
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-devel
fi
- name: Create and push manifest list for bazalt-runtime
run: |
MANIFEST=bazalt-runtime
FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
buildah manifest create $MANIFEST
for digest in ${{ runner.temp }}/digests/digest-bazalt-runtime-*; do
echo "Adding $(cat $digest)"
buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest)
done
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.BAZALT_VERSION }}-runtime
if [ "${{ env.BAZALT_VERSION }}" == "${{ env.BAZALT_LATEST_VERSION }}" ]; then
buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-runtime
fi