Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 74 additions & 24 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
kernel_pin:
description: "The full kernel version to pin"
type: string
previous_build:
description: 'Set a reference to a previous build to make updates smaller'
type: string

env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
Expand Down Expand Up @@ -52,8 +55,14 @@ jobs:
with:
submodules: recursive

- name: Maximize build space
uses: ublue-os/remove-unwanted-software@695eb75bc387dbcd9685a8e72d23439d8686cba6 # v10
- name: Mount BTRFS for podman storage
id: container-storage-action
uses: ublue-os/container-storage-action@dc1f4c8f17b672069e921f001132f7cf98a423a6
continue-on-error: true
with:
target-dir: /var/lib/containers
mount-opts: compress-force=zstd:2
loopback-free: '1'

- name: Install Just
run: |
Expand Down Expand Up @@ -135,12 +144,26 @@ jobs:
path: /var/tmp/buildah-cache-*
key: ${{ runner.os }}-${{ runner.arch }}-buildah-${{ env.CACHE_NAME }}

- name: Rechunk Image with rpm-ostree
id: rechunker
env:
MATRIX_BASE_NAME: ${{ matrix.base_name }}
MATRIX_STREAM_NAME: ${{ matrix.stream_name }}
MATRIX_IMAGE_FLAVOR: ${{ matrix.image_flavor }}
DEFAULT_TAG: ${{ env.DEFAULT_TAG }}
PREVIOUS_BUILD: ${{ github.event.inputs.previous_build || '1' }}
run: |
sudo -E $(command -v just) rechunk "${MATRIX_BASE_NAME}" \
"${MATRIX_STREAM_NAME}" \
"${MATRIX_IMAGE_FLAVOR}" \
"1" \
"0" \
"${PREVIOUS_BUILD}"

- name: Setup Syft
id: setup-syft
if: github.event_name != 'pull_request'
uses: anchore/sbom-action/download-syft@e22c389904149dbc22b58101806040fa8d37a610 # v0
with:
syft-version: v1.39.0
uses: anchore/sbom-action/download-syft@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0

- name: Generate SBOM
if: github.event_name != 'pull_request'
Expand All @@ -156,32 +179,45 @@ jobs:
"${MATRIX_IMAGE_FLAVOR}" \
"${SYFT_CMD}"

- name: Rechunk Image
id: rechunk-image
- name: Secureboot Check
id: secureboot
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sudo -E $(command -v just) rechunk "${{ matrix.base_name }}" \
"${{ matrix.stream_name }}" \
"${{ matrix.image_flavor }}" \
"1"
sudo -E $(command -v just) secureboot "${{ matrix.base_name }}" \
"${{ env.DEFAULT_TAG }}" \
"${{ matrix.image_flavor }}"

- name: Load Image into Podman
id: load-rechunk
shell: bash
- name: Export to OCI Archive
if: github.event_name == 'pull_request'
id: oci-archive
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}
DEFAULT_TAG: ${{ env.DEFAULT_TAG }}
run: |
sudo -E $(command -v just) load-rechunk "${{ matrix.base_name }}" \
sudo -E $(command -v just) export-oci "${{ matrix.base_name }}" \
"${{ env.DEFAULT_TAG }}" \
"${{ matrix.image_flavor }}"

- name: Secureboot Check
id: secureboot
shell: bash
- name: Upload OCI dir as Artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: ${{ env.IMAGE_NAME }}.oci
path: ${{ env.IMAGE_NAME }}.oci
archive: false
if-no-files-found: error
retention-days: 1

- name: PR Testing Instructions
if: github.event_name == 'pull_request'
id: pr-summary
env:
IMAGE_NAME: ${{ env.IMAGE_NAME }}
MATRIX_STREAM_NAME: "${{ matrix.stream_name }}"
run: |
sudo -E $(command -v just) secureboot "${{ matrix.base_name }}" \
"${{ env.DEFAULT_TAG }}" \
"${{ matrix.image_flavor }}"
echo "Download the .oci file" >> $GITHUB_STEP_SUMMARY
echo "Rebase: sudo bootc switch --transport oci-archive /path/to/${IMAGE_NAME}.oci" >> $GITHUB_STEP_SUMMARY
echo "Go back to the production image e.g.: sudo bootc switch --enforce-container-sigpolicy ghcr.io/ublue-os/${IMAGE_NAME}:${MATRIX_STREAM_NAME}" >> $GITHUB_STEP_SUMMARY

- name: Generate tags
id: generate-tags
Expand Down Expand Up @@ -218,10 +254,18 @@ jobs:
with:
string: ${{ env.IMAGE_REGISTRY }}

# TODO: remove me when we have a new podman in 26.04 runners
# needed because old podman doesn't push layer annotations for
# the rpm-ostree rechunker at all
- name: install podman from brew
if: github.event_name != 'pull_request'
run: |
/home/linuxbrew/.linuxbrew/bin/brew install podman

- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | podman login ghcr.io -u ${{ github.actor }} --password-stdin
echo ${{ secrets.GITHUB_TOKEN }} | /home/linuxbrew/.linuxbrew/bin/podman login ghcr.io -u ${{ github.actor }} --password-stdin
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push to GHCR
Expand All @@ -234,6 +278,12 @@ jobs:
timeout_minutes: 30
command: |
set -euox pipefail
# HACK: push a second time so layer annotations are pushed
# TODO: remove me when https://github.com/containers/podman/issues/27796 fixed

for tag in ${{ steps.generate-tags.outputs.alias_tags }}; do
sudo -E /home/linuxbrew/.linuxbrew/bin/podman push --compression-format=zstd --compression-level=3 ${{ env.IMAGE_NAME }}:${tag} ${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}:${tag}
done

digest_file="$PWD/.push-digest"
for tag in ${{ steps.generate-tags.outputs.alias_tags }}; do
Expand Down
Loading