Skip to content

Instantly share code, notes, and snippets.

@gbraad
Last active March 10, 2025 07:52
Show Gist options
  • Save gbraad/f8a46c5958d158707d18a333a414a900 to your computer and use it in GitHub Desktop.
Save gbraad/f8a46c5958d158707d18a333a414a900 to your computer and use it in GitHub Desktop.
Multi-arch build with Podman using GitHub Actions

Multi-arch build with Podman using GitHub Actions

build-process.yml

name: Build process

on:
  workflow_dispatch:
  schedule:
    - cron: "0 1 * * *"
  push:
    branches:
      - "main"
  pull_request: {}

jobs:

  build_aarch64:
    name: Build aarch64
    runs-on: ubuntu-24.04-arm
    steps:
      - name: Install missing package
        run: |
          sudo apt-get update
          sudo apt-get install -y \
            podman
      ...
      - name: Build
        run: |
          sudo podman build --security-opt=label=disable --cap-add=all --device /dev/fuse -t localhost/centos-bootc:aarch64 .
      - name: Save
        run: |
          sudo podman save localhost/centos-bootc:aarch64 --format=oci-dir -o oci-aarch64
      - uses: actions/upload-artifact@v4
        with:
          name: oci-aarch64
          path: oci-aarch64/


  build_x86_64:
    name: Build x86_64
    runs-on: ubuntu-24.04
    steps:
      ...
      - name: Build
        run: |
          sudo podman build --security-opt=label=disable --cap-add=all --device /dev/fuse -t localhost/centos-bootc:x86_64 .
      - name: Save
        run: |
          sudo podman save localhost/centos-bootc:x86_64 --format=oci-dir -o oci-x86_64
      - uses: actions/upload-artifact@v4
        with:
          name: oci-x86_64
          path: oci-x86_64/


  push:
    name: Push images
    needs: 
      - build_aarch64
      - build_x86_64
    runs-on: ubuntu-24.04
    steps:
      - name: Download aarch64
        uses: actions/download-artifact@v4
        with:
          name: oci-aarch64
          path: oci-aarch64
      - name: Download x86_64
        uses: actions/download-artifact@v4
        with:
          name: oci-x86_64
          path: oci-x86_64
          
      - name: Create manifest
        run: |
          podman manifest create centos-bootc-manifest
      - name: Add aarch64 to manifest
        run: |
          podman manifest add centos-bootc-manifest oci:$(pwd)/oci-aarch64
      - name: Add x86_64 to manifest
        run: |
          podman manifest add centos-bootc-manifest oci:$(pwd)/oci-x86_64
        
      - name: Push latest
        run: |
          podman manifest push centos-bootc-manifest docker://ghcr.io/gbraad-centos/centos-bootc:latest  
      - name: Push
        if: github.event_name != 'pull_request'
        run: |
          podman manifest push centos-bootc-manifest docker://ghcr.io/gbraad-centos/centos-bootc:stream9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment