Skip to content

Commit

Permalink
Build multiarch images
Browse files Browse the repository at this point in the history
Signed-off-by: You-Sheng Yang <[email protected]>
  • Loading branch information
vicamo committed Jun 11, 2024
1 parent e70bc99 commit 8c103ce
Showing 1 changed file with 83 additions and 25 deletions.
108 changes: 83 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
branches:
- master
workflow_dispatch:
inputs:
include_eol:
description: 'Build also EOL-ed suites'
type: boolean
default: false
schedule:
- cron: 0 0 * * 0

Expand All @@ -22,42 +27,95 @@ concurrency:
permissions:
contents: read

env:
INCLUDE_EOL: ${{ inputs.include_eol && 'true' || '' }}

jobs:

generate-jobs:
name: Generate Jobs
runs-on: ubuntu-latest
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
codenames: ${{ steps.generate-jobs.outputs.codenames }}
steps:
- uses: actions/checkout@v3
- uses: docker-library/bashbrew@HEAD
- name: Debian Releases Info
id: debian
uses: vicamo/actions-library/debian-releases@v1
- name: Ubuntu Releases Info
id: ubuntu
uses: vicamo/actions-library/ubuntu-releases@v1
- id: generate-jobs
name: Generate Jobs
env:
DEBIAN_JSON: ${{ steps.debian.outputs.json }}
UBUNTU_JSON: ${{ steps.ubuntu.outputs.json }}
run: |
strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")"
disabled_codename='["experimental"]'
codenames="$(jq -n -c -M \
--argjson debian "${DEBIAN_JSON}" \
--argjson ubuntu "${UBUNTU_JSON}" \
'$debian + $ubuntu |
map(select(.codename as $c | '"${disabled_codename}"' |
index($c) == null)) |
map({
"distribution":.distribution,
"codename":.codename,
"suite":.suite,
"active":.active,
})
')"
if [ -z "${INCLUDE_EOL}" ]; then
codenames="$(echo "${codenames}" | jq -c -M 'map(select(.active))')"
fi
EOF="EOF-$RANDOM-$RANDOM-$RANDOM"
echo "strategy<<$EOF" >> "$GITHUB_OUTPUT"
jq <<<"$strategy" . | tee -a "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
echo "::group::Built JSON(codenames)"
echo "${codenames}" | jq
echo "::endgroup::"
test:
echo "codenames=${codenames}" | tee -a "${GITHUB_OUTPUT}"
build:
needs: generate-jobs
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-jobs.outputs.codenames) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare Environment
run: ${{ matrix.runs.prepare }}
- name: Pull Dependencies
run: ${{ matrix.runs.pull }}
- name: Build ${{ matrix.name }}
run: ${{ matrix.runs.build }}
- name: History ${{ matrix.name }}
run: ${{ matrix.runs.history }}
- name: Test ${{ matrix.name }}
run: ${{ matrix.runs.test }}
- name: '"docker images"'
run: ${{ matrix.runs.images }}
- name: Set up QEMU
run: |
echo "deb http://archive.ubuntu.com/ubuntu/ devel main universe" | \
sudo tee /etc/apt/sources.list.d/devel.list
sudo apt-get update -q
sudo apt-get install -yq binfmt-support qemu-user-static systemd
ls -al /proc/sys/fs/binfmt_misc
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: all

- name: Login to Docker Hub
if: ${{ github.ref_name == 'master' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.username }}
password: ${{ secrets.password }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: 'vicamo/buildpack-deps'
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index

- env:
DISTRO: ${{ matrix.distribution }}
CODENAME: ${{ matrix.codename }}
SUITE: ${{ matrix.suite }}
ACTIVE: ${{ matrix.active && 'true' || '' }}
run: |
docker buildx imagetools inspect --raw vicamo/${DISTRO}:${CODENAME}

0 comments on commit 8c103ce

Please sign in to comment.