33 lines
No EOL
1.3 KiB
Bash
Executable file
33 lines
No EOL
1.3 KiB
Bash
Executable file
#!/bin/env sh
|
|
|
|
set -e
|
|
|
|
# Change to the directory where the script is located
|
|
cd "$(dirname "$0")"
|
|
|
|
DATE_TAG=$(date "+%Y%m%d-%H%M%S")
|
|
CURRENT_IMAGE_ID=$(sudo podman images --format "{{.ID}}" cremin.dev/jonathan/ublue-silverblue-main:42)
|
|
|
|
|
|
echo "Pulling base image"
|
|
# ensure the base image is up to date
|
|
sudo -E podman pull ghcr.io/ublue-os/silverblue-main:42
|
|
|
|
echo "Starting build"
|
|
sudo -E podman build -t cremin.dev/jonathan/ublue-silverblue-main:42 .
|
|
|
|
NEW_IMAGE_ID=$(sudo podman images --format "{{.ID}}" cremin.dev/jonathan/ublue-silverblue-main:42)
|
|
|
|
|
|
# Start build and check if any layers were changed (looking for "Using cache" messages)
|
|
if [ "$CURRENT_IMAGE_ID" = "$NEW_IMAGE_ID" ]; then
|
|
echo "No changes detected, skipping push"
|
|
else
|
|
echo "Image updated, pushing to registry"
|
|
# Add the tags
|
|
sudo -E podman tag cremin.dev/jonathan/ublue-silverblue-main:42 cremin.dev/jonathan/ublue-silverblue-main:42-${DATE_TAG} cremin.dev/jonathan/ublue-silverblue-main:latest
|
|
# Push the image
|
|
sudo -E podman push --authfile ~/.config/containers/auth.json cremin.dev/jonathan/ublue-silverblue-main:42-${DATE_TAG}
|
|
sudo -E podman push --authfile ~/.config/containers/auth.json cremin.dev/jonathan/ublue-silverblue-main:42
|
|
sudo -E podman push --authfile ~/.config/containers/auth.json cremin.dev/jonathan/ublue-silverblue-main:latest
|
|
fi |