Skip to content

Commit

Permalink
chore: reorder action to speed up + lower image size
Browse files Browse the repository at this point in the history
  • Loading branch information
antheas committed Oct 25, 2024
1 parent befbfee commit 0e2a8bd
Showing 1 changed file with 33 additions and 48 deletions.
81 changes: 33 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ jobs:
- base_name: bazzite-deck
target_nvidia_flavor: nvidia
steps:
- name: Login to GHCR (fail fast)
uses: Wandalen/wretry.action@v3.5.0
if: github.event_name != 'pull_request'
with:
attempt_limit: 3
attempt_delay: 15000
commands: |
echo "${{ secrets.GITHUB_TOKEN }}" | sudo podman login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Define env.IMAGE_FLAVOR
run: |
if [[ "${{ matrix.base_name }}" == "bazzite-nvidia" ]]; then
Expand Down Expand Up @@ -268,6 +277,25 @@ jobs:
echo "Generated the following:"
cat $GITHUB_OUTPUT
- name: Check Secureboot
shell: bash
run: |
set -x
if [[ ! $(command -v sbverify) || ! $(command -v curl) || ! $(command -v openssl) ]]; then
sudo apt update
sudo apt install sbsigntool curl openssl
fi
TMP=$(podman create raw-img bash)
podman cp $TMP:/usr/lib/modules/${{ matrix.kernel_version }}/vmlinuz .
podman rm $TMP
sbverify --list vmlinuz
curl --retry 3 -Lo kernel-sign.der https://github.com/ublue-os/kernel-cache/raw/main/certs/public_key.der
curl --retry 3 -Lo akmods.der https://github.com/ublue-os/kernel-cache/raw/main/certs/public_key_2.der
openssl x509 -in kernel-sign.der -out kernel-sign.crt
openssl x509 -in akmods.der -out akmods.crt
sbverify --cert kernel-sign.crt vmlinuz || exit 1
sbverify --cert akmods.crt vmlinuz || exit 1
# Reprocess raw-img using rechunker which will delete it
- name: Run Rechunker
id: rechunk
Expand Down Expand Up @@ -321,9 +349,6 @@ jobs:
BUILD_TAGS+=("${FEDORA_VERSION}-unstable")
BUILD_TAGS+=("unstable-${FEDORA_VERSION}") # flip ver to be last
# Per upstream ver
BUILD_TAGS+=("unstable-${UPSTREAM_TAG}")
if [ -n "$LATEST" ]; then
BUILD_TAGS+=("unstable")
fi
Expand All @@ -332,16 +357,12 @@ jobs:
BUILD_TAGS+=("${FEDORA_VERSION}-testing")
BUILD_TAGS+=("testing-${FEDORA_VERSION}") # flip ver to be last
# Per upstream ver
BUILD_TAGS+=("testing-${UPSTREAM_TAG}")
if [ -n "$LATEST" ]; then
BUILD_TAGS+=("testing")
fi
else
BUILD_TAGS+=("${FEDORA_VERSION}")
BUILD_TAGS+=("${UPSTREAM_TAG}")
BUILD_TAGS+=("stable-${UPSTREAM_TAG}")
BUILD_TAGS+=("stable-${VERSION_TAG}")
# Per fedora version
BUILD_TAGS+=("${FEDORA_VERSION}-stable")
Expand All @@ -358,36 +379,6 @@ jobs:
done
echo "alias_tags=${BUILD_TAGS[*]}" >> $GITHUB_OUTPUT
# Pull oci-dir image, remove oci dir to make space, and then tag appropriately
- name: Load in podman and tag
run: |
IMAGE=$(podman pull ${{ steps.rechunk.outputs.ref }})
sudo rm -rf ${{ steps.rechunk.outputs.output }}
for tag in ${{ steps.generate-tags.outputs.alias_tags }}; do
podman tag $IMAGE ${{ env.IMAGE_NAME }}:$tag
done
# keep for secureboot check
podman tag $IMAGE rechunked-img
- name: Check Secureboot
shell: bash
run: |
set -x
if [[ ! $(command -v sbverify) || ! $(command -v curl) || ! $(command -v openssl) ]]; then
sudo apt update
sudo apt install sbsigntool curl openssl
fi
TMP=$(podman create rechunked-img bash)
podman cp $TMP:/usr/lib/modules/${{ matrix.kernel_version }}/vmlinuz .
podman rm $TMP
sbverify --list vmlinuz
curl --retry 3 -Lo kernel-sign.der https://github.com/ublue-os/kernel-cache/raw/main/certs/public_key.der
curl --retry 3 -Lo akmods.der https://github.com/ublue-os/kernel-cache/raw/main/certs/public_key_2.der
openssl x509 -in kernel-sign.der -out kernel-sign.crt
openssl x509 -in akmods.der -out akmods.crt
sbverify --cert kernel-sign.crt vmlinuz || exit 1
sbverify --cert akmods.crt vmlinuz || exit 1
# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR.
# https://github.com/macbre/push-to-ghcr/issues/12
- name: Lowercase Registry
Expand All @@ -401,19 +392,13 @@ jobs:
uses: Wandalen/wretry.action@v3.5.0
id: push
if: github.event_name != 'pull_request'
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
with:
action: redhat-actions/push-to-registry@v2
attempt_limit: 3
attempt_delay: 15000
with: |
image: ${{ env.IMAGE_NAME }}
tags: ${{ steps.generate-tags.outputs.alias_tags }}
registry: ${{ steps.registry_case.outputs.lowercase }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
commands: |
for tag in ${{ steps.generate-tags.outputs.alias_tags }}; do
sudo skopeo copy ${{ steps.rechunk.outputs.ref }} docker://${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}:$tag
done
- name: Sign container image
uses: EyeCantCU/cosign-action/sign@v0.3.0
Expand Down

0 comments on commit 0e2a8bd

Please sign in to comment.