Skip to content

Commit

Permalink
Merge pull request #283 from chase-qi/build-arm64
Browse files Browse the repository at this point in the history
ci: build container image for arm64
  • Loading branch information
vi authored Feb 27, 2025
2 parents 83c4375 + bd2b03c commit cc94a0a
Showing 1 changed file with 69 additions and 5 deletions.
74 changes: 69 additions & 5 deletions .github/workflows/container-image-buildah.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,38 @@ permissions:

jobs:
buildah:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- architecture: amd64
runner: ubuntu-latest
- architecture: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- name: Sanitize Platforms
id: platforms
run: |
platforms="${{ inputs.platforms == '' && 'linux/amd64' || inputs.platforms }}"
archs="$( sed -e 's#linux/##g' <<< $platforms )"
platforms="${{ inputs.platforms == '' && 'linux/amd64,linux/arm64' || inputs.platforms }}"
if [ "${{ matrix.architecture }}" = "arm64" ]; then
platforms="linux/arm64"
else
platforms="$( sed -e 's#linux/arm64,##g' -e 's#,linux/arm64##g' -e 's#linux/arm64##g' <<< $platforms)"
archs="$( sed -e 's#linux/##g' <<< $platforms )"
echo "archs=$archs" >> $GITHUB_OUTPUT
fi
echo "platforms=$platforms" >> $GITHUB_OUTPUT
echo "archs=$archs" >> $GITHUB_OUTPUT
- name: Install Podman on ubuntu-24.04-arm
if: matrix.architecture == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y podman
echo -e "[registries.search]\nregistries = ['docker.io']" | sudo tee /etc/containers/registries.conf
# Allow multi-target builds
- name: Set up QEMU
if: matrix.architecture == 'amd64'
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ steps.platforms.outputs.archs }}
Expand All @@ -77,7 +97,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.architecture }}
tags: |
type=schedule
type=raw,value=latest,enable=${{ github.ref_name == 'master' }}
Expand Down Expand Up @@ -152,3 +172,47 @@ jobs:

- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-container-registry.outputs.registry-paths }}"

merge-archs:
runs-on: ubuntu-latest
needs: buildah
steps:
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule
type=raw,value=latest,enable=${{ github.ref_name == 'master' }}
${{ github.ref_name == 'master' && 'type=raw,value=nightly' }}
type=ref,event=branch,enable=${{ github.ref_name != 'master' && inputs.custom_tag == '' }}
${{ inputs.custom_tag }}
type=ref,event=tag
type=ref,event=pr
- name: Create and push manifest
run: |
set -x
img="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
podman manifest create $img
archs="amd64 arm64"
for arch in $archs; do
podman manifest add $img "${img}-${arch}:latest"
done
tags="${{ steps.meta.outputs.tags }}"
for tag in $tags; do
podman tag $img $tag
podman manifest push --all $tag
done

0 comments on commit cc94a0a

Please sign in to comment.