Skip to content

Build and push images #65

Build and push images

Build and push images #65

Workflow file for this run

name: Build and push images
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/chimera
# Chimera linux version
VERSION: 20240707
# architectures available in the main manifest
ARCHS: x86_64 aarch64 riscv64 ppc64 ppc64le
CROSS_ARCHS: x86_64
on:
push:
schedule:
# rebuild on mondays
- cron: '0 19 * * 1'
workflow_dispatch:
jobs:
build:
name: ${{ matrix.config.arch }} build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
strategy:
fail-fast: false
matrix:
config:
- arch: x86_64
platform: linux/amd64
- arch: aarch64
platform: linux/arm64
- arch: riscv64
platform: linux/riscv64
- arch: ppc64
platform: linux/ppc64
- arch: ppc64le
platform: linux/ppc64le
steps:
- uses: actions/checkout@v4
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_NAME }}
- name: Build image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
platforms: ${{ matrix.config.platform }}
image: ${{ env.IMAGE_NAME }}
tags: ${{ github.sha }}-${{ matrix.config.arch }} ${{ matrix.config.arch }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
ARCH=${{ matrix.config.arch }}
VERSION=${{ env.VERSION }}
containerfiles: Containerfile
- name: Push image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ github.sha }}-${{ matrix.config.arch }}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push arch image
if: github.ref == 'refs/heads/main'
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ matrix.config.arch }}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
push_manifest:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- uses: actions/checkout@v4
- name: Podman login
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: create and push manifest for supported platforms
run: |
image_base=${{ env.IMAGE_NAME }}:${{ github.sha }}
podman manifest create $image_base
archs="${{ env.ARCHS }}"
for arch in $archs; do
podman pull ${{ env.REGISTRY }}/$image_base-$arch
podman manifest add $image_base ${{ env.REGISTRY }}/$image_base-$arch
done
podman manifest push $image_base ${{ env.REGISTRY }}/$image_base
podman manifest push $image_base ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
build_cross:
needs: build
runs-on: ${{ matrix.config.gh_image }}
strategy:
fail-fast: false
matrix:
config:
- arch: x86_64
gh_image: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- uses: actions/checkout@v4
- name: Docker Metadata
id: meta-cross
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_NAME }}
- name: Build image
id: build-cross-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: cross-${{ matrix.config.arch }} cross-${{ github.sha }}-${{ matrix.config.arch }}
labels: ${{ steps.meta-cross.outputs.labels }}
build-args: |
TAG=${{ github.sha }}-${{ matrix.config.arch }}
containerfiles: Containerfile.cross
- name: Push image
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-cross-image.outputs.image }}
tags: cross-${{ github.sha }}-${{ matrix.config.arch }} cross-${{ matrix.config.arch }}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
push_cross_manifest:
needs: build_cross
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- uses: actions/checkout@v4
- name: Podman login
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: create and push manifest for supported platforms
run: |
image_base=${{ env.IMAGE_NAME }}:cross-${{ github.sha }}
podman manifest create $image_base
archs="${{ env.CROSS_ARCHS }}"
for arch in $archs; do
podman pull ${{ env.REGISTRY }}/$image_base-$arch
podman manifest add $image_base ${{ env.REGISTRY }}/$image_base-$arch
done
podman manifest push $image_base ${{ env.REGISTRY }}/$image_base
podman manifest push $image_base ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cross