|
| 1 | +name: build bootc and bootc image |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ main ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + os: [ubuntu-latest, ubuntu-24.04-arm] |
| 12 | + # os: [ubuntu-latest] |
| 13 | + # distro: [fedora-41, fedora-42, fedora-r43, centos-stream-9, centos-stream-10] |
| 14 | + distro: [centos-stream-9] |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + |
| 17 | + # Required to push container image to ghcr.io |
| 18 | + # https://github.com/orgs/community/discussions/57724 |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + attestations: write |
| 23 | + id-token: write |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Build bootc RPM |
| 29 | + env: |
| 30 | + DISTRO: ${{ matrix.distro }} |
| 31 | + BUILD_IMAGE: quay.io/fedora/fedora:42 |
| 32 | + run: | |
| 33 | + podman run \ |
| 34 | + --rm \ |
| 35 | + --privileged \ |
| 36 | + -v $(pwd):/workdir:z \ |
| 37 | + -e DISTRO=$DISTRO \ |
| 38 | + --workdir /workdir \ |
| 39 | + $BUILD_IMAGE \ |
| 40 | + contrib/scripts/mock_build.sh |
| 41 | +
|
| 42 | + - name: Re-build bootc image with new bootc PRM |
| 43 | + env: |
| 44 | + DISTRO: ${{ matrix.distro }} |
| 45 | + run: | |
| 46 | + set -xeu |
| 47 | + if [[ $DISTRO =~ fedora ]]; then |
| 48 | + VERSION_ID=$(cut -d'-' -f2 <<<"$DISTRO") |
| 49 | + BASE_IMAGE="quay.io/fedora/fedora-bootc:${VERSION_ID}" |
| 50 | + fi |
| 51 | + if [[ $DISTRO =~ centos ]]; then |
| 52 | + VERSION_ID=$(cut -d'-' -f3 <<<"$DISTRO") |
| 53 | + BASE_IMAGE="quay.io/centos-bootc/centos-bootc:stream${VERSION_ID}" |
| 54 | + fi |
| 55 | +
|
| 56 | + tee target/build/Containerfile >/dev/null <<CONTAINERFILEEOF |
| 57 | + FROM $BASE_IMAGE |
| 58 | + RUN dnf -y upgrade /rpms/*.rpm && dnf -y clean all && rm -rf /var/cache /var/lib/dnf |
| 59 | + CONTAINERFILEEOF |
| 60 | + cat target/build/Containerfile |
| 61 | +
|
| 62 | + IMAGE_NAME="bootc-image:${{ github.sha }}-$(uname -m)" |
| 63 | + buildah build -v "$(pwd)/target/build/":/rpms:z -t $IMAGE_NAME target/build |
| 64 | + buildah login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io |
| 65 | + buildah push $IMAGE_NAME "docker://ghcr.io/${{ github.event.pull_request.head.repo.full_name }}/$IMAGE_NAME" |
| 66 | +
|
| 67 | + push: |
| 68 | + needs: build |
| 69 | + runs-on: ubuntu-latest |
| 70 | + |
| 71 | + # Required to push container image to ghcr.io |
| 72 | + # https://github.com/orgs/community/discussions/57724 |
| 73 | + permissions: |
| 74 | + contents: read |
| 75 | + packages: write |
| 76 | + attestations: write |
| 77 | + id-token: write |
| 78 | + |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: Push manifest |
| 83 | + env: |
| 84 | + ARCHES: "x86_64 aarch64" |
| 85 | + run: | |
| 86 | + set -xeuo pipefail |
| 87 | + REGISTRY_NAME="ghcr.io/${{ github.event.pull_request.head.repo.full_name }}/bootc-image" |
| 88 | + buildah login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io |
| 89 | +
|
| 90 | + for arch in $ARCHES; do |
| 91 | + buildah pull "${REGISTRY_NAME}:${{ github.sha }}-${arch}" |
| 92 | + done |
| 93 | +
|
| 94 | + buildah manifest create "${REGISTRY_NAME}:${{ github.sha }}" `for arch in ${ARCHES}; do echo "${REGISTRY_NAME}:${{ github.sha }}-${arch};" done` |
| 95 | +
|
| 96 | + for arch in ${ARCHES}; do |
| 97 | + buildah manifest annotate "${REGISTRY_NAME}:${{ github.sha }}" "${REGISTRY_NAME}:${{ github.sha }}-${arch}" --os linux --arch ${arch} |
| 98 | + done |
| 99 | + buildah tag "${REGISTRY_NAME}:${{ github.sha }}" |
| 100 | + buildah manifest push --all "${REGISTRY_NAME}:${{ github.sha }}" docker://"${REGISTRY_NAME}:${{ github.sha }}" |
0 commit comments