Update GitHub Actions workflow for build process
This commit is contained in:
+20
-56
@@ -30,22 +30,23 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Prepare environment
|
- name: Prepare environment
|
||||||
run: |
|
run: |
|
||||||
|
# Lowercase the image uri
|
||||||
echo "IMAGE_REGISTRY=${IMAGE_REGISTRY,,}" >> ${GITHUB_ENV}
|
echo "IMAGE_REGISTRY=${IMAGE_REGISTRY,,}" >> ${GITHUB_ENV}
|
||||||
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}
|
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v5
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Mount BTRFS for podman storage
|
- name: Mount BTRFS for podman storage
|
||||||
id: container-storage-action
|
id: container-storage-action
|
||||||
uses: ublue-os/container-storage-action@911baca08baf30c8654933e9e9723cb399892140 # main
|
uses: ublue-os/container-storage-action@main
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
target-dir: /var/lib/containers
|
target-dir: /var/lib/containers
|
||||||
mount-opts: compress-force=zstd:2
|
mount-opts: compress-force=zstd:2
|
||||||
|
|
||||||
- name: Image Metadata
|
- name: Image Metadata
|
||||||
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v5
|
uses: docker/metadata-action@v5
|
||||||
id: metadata
|
id: metadata
|
||||||
with:
|
with:
|
||||||
tags: |
|
tags: |
|
||||||
@@ -80,7 +81,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Image
|
- name: Build Image
|
||||||
id: build_image
|
id: build_image
|
||||||
uses: redhat-actions/buildah-build@7a95fa7ee0f02d552a32753e7414641a04307056 # v2
|
uses: redhat-actions/buildah-build@v2
|
||||||
with:
|
with:
|
||||||
containerfiles: |
|
containerfiles: |
|
||||||
./Containerfile
|
./Containerfile
|
||||||
@@ -89,66 +90,30 @@ jobs:
|
|||||||
labels: ${{ steps.metadata.outputs.labels }}
|
labels: ${{ steps.metadata.outputs.labels }}
|
||||||
oci: true
|
oci: true
|
||||||
|
|
||||||
- name: Apply chunkah optimization
|
# Intelligentes Rechunking auf RPM-Paketbasis mit maximal 128 Layern
|
||||||
id: chunkah
|
- name: Apply native bootc rechunking
|
||||||
|
id: rechunk
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
BASE_IMAGE="${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}"
|
BASE_IMAGE="localhost/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}"
|
||||||
|
mkdir -p ./chunkah-out
|
||||||
# 1. Das originale ostree-Label im Runner auslesen und sichern
|
|
||||||
OSTREE_DIFFID=$(podman inspect $BASE_IMAGE --format '{{index .Config.Labels "ostree.final-diffid"}}' 2>/dev/null || echo "")
|
|
||||||
|
|
||||||
# Rootfs extrahieren
|
rpm-ostree compose build-chunked-oci \
|
||||||
CONTAINER_ID=$(podman create $BASE_IMAGE)
|
--bootc \
|
||||||
mkdir -p ./chunkah-in ./chunkah-out
|
--format-version=2 \
|
||||||
podman export $CONTAINER_ID | tar -xf - -C ./chunkah-in
|
|
||||||
podman rm $CONTAINER_ID
|
|
||||||
|
|
||||||
# Die originale Image-Config extrahieren
|
|
||||||
podman inspect $BASE_IMAGE --format '{{json .Config}}' > ./chunkah-config.json
|
|
||||||
|
|
||||||
# Chunkah-Lauf
|
|
||||||
podman run --rm \
|
|
||||||
-v ./chunkah-in:/inputs:z \
|
|
||||||
-v ./chunkah-out:/outputs:z \
|
|
||||||
-v ./chunkah-config.json:/config.json:z \
|
|
||||||
quay.io/coreos/chunkah:latest \
|
|
||||||
build \
|
|
||||||
--config /config.json \
|
|
||||||
--prune /sysroot/ \
|
|
||||||
--max-layers 128 \
|
--max-layers 128 \
|
||||||
--compressed \
|
--from=$BASE_IMAGE \
|
||||||
--output /outputs/image.ociarchive \
|
--output=oci-archive:./chunkah-out/image.ociarchive
|
||||||
--rootfs /inputs
|
|
||||||
|
|
||||||
# 2. Das von Chunkah erzeugte Archiv wieder laden und das OCI-Label fest einbrennen
|
|
||||||
if [ ! -z "$OSTREE_DIFFID" ]; then
|
|
||||||
podman load -i ./chunkah-out/image.ociarchive
|
|
||||||
|
|
||||||
# dangling-ID des neuen Images greifen
|
|
||||||
OPT_IMAGE_ID=$(podman images --filter "dangling=true" --format "{{.ID}}" | head -n 1)
|
|
||||||
|
|
||||||
# Ein modifiziertes OCI-Image mit Buildah erstellen (erhält die OCI-Struktur exakt aufrecht)
|
|
||||||
BUILDAH_CONTAINER=$(buildah from $OPT_IMAGE_ID)
|
|
||||||
buildah config --label "ostree.final-diffid=$OSTREE_DIFFID" $BUILDAH_CONTAINER
|
|
||||||
|
|
||||||
# Altes Archiv löschen und durch das final gelabelte OCI-Archiv ersetzen
|
|
||||||
rm ./chunkah-out/image.ociarchive
|
|
||||||
buildah commit --rm $BUILDAH_CONTAINER oci-archive:./chunkah-out/image.ociarchive
|
|
||||||
|
|
||||||
# Lokalen Speicher aufräumen
|
|
||||||
podman rmi $OPT_IMAGE_ID || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v3
|
uses: docker/login-action@v3
|
||||||
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Push to GHCR via Skopeo
|
- name: Push to GHCR via Skopeo (with ZSTD Compression)
|
||||||
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
@@ -156,7 +121,7 @@ jobs:
|
|||||||
export REGISTRY_AUTH_FILE=$HOME/.docker/config.json
|
export REGISTRY_AUTH_FILE=$HOME/.docker/config.json
|
||||||
REGISTRY_PATH="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}"
|
REGISTRY_PATH="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||||
|
|
||||||
# Loop über alle Tags
|
# Loop über alle generierten Tags aus dem Metadata-Schritt
|
||||||
for tag in ${{ steps.metadata.outputs.tags }}; do
|
for tag in ${{ steps.metadata.outputs.tags }}; do
|
||||||
skopeo copy \
|
skopeo copy \
|
||||||
--dest-compress-format=zstd \
|
--dest-compress-format=zstd \
|
||||||
@@ -165,18 +130,17 @@ jobs:
|
|||||||
docker://$REGISTRY_PATH:$tag
|
docker://$REGISTRY_PATH:$tag
|
||||||
done
|
done
|
||||||
|
|
||||||
# KORREKTUR: Wir fragen den echten, finalen Digest direkt von GHCR ab
|
# Den echten, von der Registry vergebenen Manifest-Digest abfragen
|
||||||
FINAL_REGISTRY_DIGEST=$(skopeo inspect docker://$REGISTRY_PATH:${{ env.DEFAULT_TAG }} --format '{{.Digest}}')
|
FINAL_REGISTRY_DIGEST=$(skopeo inspect docker://$REGISTRY_PATH:${{ env.DEFAULT_TAG }} --format '{{.Digest}}')
|
||||||
echo "REGISTRY_DIGEST=$FINAL_REGISTRY_DIGEST" >> $GITHUB_ENV
|
echo "REGISTRY_DIGEST=$FINAL_REGISTRY_DIGEST" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Install Cosign
|
- name: Install Cosign
|
||||||
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
|
uses: sigstore/cosign-installer@v4
|
||||||
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
||||||
|
|
||||||
- name: Sign container image
|
- name: Sign container image
|
||||||
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
|
||||||
run: |
|
run: |
|
||||||
# Signiert den exakten, von der Registry bestätigten Digest
|
|
||||||
cosign sign -y --key env://COSIGN_PRIVATE_KEY "${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}@${{ env.REGISTRY_DIGEST }}"
|
cosign sign -y --key env://COSIGN_PRIVATE_KEY "${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}@${{ env.REGISTRY_DIGEST }}"
|
||||||
env:
|
env:
|
||||||
COSIGN_EXPERIMENTAL: false
|
COSIGN_EXPERIMENTAL: false
|
||||||
|
|||||||
Reference in New Issue
Block a user