Some checks failed
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-rootfs-archives (push) Failing after 4m41s
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / push-archives-to-repo (push) Has been skipped
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-and-push-docker-images (push) Has been skipped
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-changelogs (push) Has been skipped
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-build-info (push) Has been skipped
329 lines
11 KiB
YAML
329 lines
11 KiB
YAML
name: Build, Upload RootFS, and Push Docker Images, update changelog, update build info.
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- '**/CHANGES.md'
|
|
- '**/build-info.json'
|
|
- '/sha256sums.txt'
|
|
schedule:
|
|
- cron: '0 12 * * 0' # Sunday at noon UTC
|
|
|
|
env:
|
|
REPO_URL: ${{ secrets.REPO_URL }}
|
|
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
|
|
GIT_EMAIL: ${{ secrets.GIT_EMAIL }}
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
VERSIONS: "buster bullseye bookworm"
|
|
OUTPUT_DIR: /mnt/user/git/act_runner_output
|
|
|
|
jobs:
|
|
build-rootfs-archives:
|
|
runs-on: docker-build
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Check host output
|
|
run: |
|
|
mkdir -p "${{ env.OUTPUT_DIR }}"
|
|
ls -lah "${{ env.OUTPUT_DIR }}"
|
|
|
|
- name: Clean workspace tarballs before build
|
|
run: |
|
|
echo "[INFO] Cleaning old tarballs..."
|
|
rm -f ./debian-*.tar.bz2
|
|
rm -f ./rootfs-*.tar.bz2
|
|
rm -f ./sha256sums.txt
|
|
|
|
- name: Build all Debian rootfs versions sequentially
|
|
run: |
|
|
versions=($VERSIONS)
|
|
mkdir -p "${{ env.OUTPUT_DIR }}"
|
|
|
|
for version in "${versions[@]}"; do
|
|
echo "[INFO] Building $version..."
|
|
docker build --build-arg VERSION=$version -t fithwum/debian-$version-base .
|
|
|
|
docker run --rm --privileged \
|
|
-v "${{ env.OUTPUT_DIR }}:/output" \
|
|
-e VERSION="$version" \
|
|
fithwum/debian-$version-base \
|
|
bash -c "ls -lh /output; ls -lh /; ls -lh /builder; /scripts/bootstrap-rootfs.sh \"$version\""
|
|
# bash -eux /scripts/bootstrap-rootfs.sh "$version"
|
|
done
|
|
|
|
- name: Verify tarball exists on host
|
|
run: |
|
|
echo "[INFO] Verifying tarballs in ${{ env.OUTPUT_DIR }}"
|
|
find "${{ env.OUTPUT_DIR }}" -type f -name '*.tar.bz2' -exec ls -lh {} \;
|
|
|
|
- name: Check output folder permissions
|
|
run: |
|
|
ls -ld "${{ env.OUTPUT_DIR }}"
|
|
ls -l "${{ env.OUTPUT_DIR }}"/*
|
|
|
|
- name: Check output folder on host
|
|
run: |
|
|
echo "Host output folder contents:"
|
|
ls -R "${{ env.OUTPUT_DIR }}"
|
|
|
|
- name: Debug output folder
|
|
run: |
|
|
echo "Archives present in output:"
|
|
find "${{ env.OUTPUT_DIR }}" -name '*.tar.bz2' -exec ls -lh {} \;
|
|
|
|
- name: List output archives
|
|
run: |
|
|
echo "[INFO] Final archive list:"
|
|
find "${{ env.OUTPUT_DIR }}" -type f -name 'debian-*.tar.bz2'
|
|
|
|
- name: Validate that archives exist for each version
|
|
run: |
|
|
for version in $VERSIONS; do
|
|
path="${{ env.OUTPUT_DIR }}/$version/debian-$version.tar.bz2"
|
|
if [[ ! -f "$path" ]]; then
|
|
echo "[ERROR] Missing archive: $path"
|
|
exit 1
|
|
else
|
|
echo "[OK] Found: $path"
|
|
fi
|
|
done
|
|
|
|
- name: Clean up Docker cache (optional)
|
|
if: always()
|
|
run: docker system prune -af || true
|
|
|
|
push-archives-to-repo:
|
|
needs: build-rootfs-archives
|
|
runs-on: docker-build
|
|
outputs:
|
|
archives_changed: ${{ steps.commit_archives.outputs.archives_changed }}
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Clone upload repo
|
|
run: |
|
|
git clone "https://${{ env.GIT_USERNAME }}:${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}@gitea.fithwum.tech/fithwum/debian-base.git" upload-repo
|
|
|
|
- name: Clean old archives in upload-repo
|
|
run: rm -rf upload-repo/*/*.tar.bz2
|
|
|
|
- name: Copy new archives to upload-repo
|
|
run: |
|
|
found=$(find "${{ env.OUTPUT_DIR }}" -type f -name 'debian-*.tar.bz2')
|
|
if [ -z "$found" ]; then
|
|
echo "[WARNING] No .tar.bz2 archive found in output/!"
|
|
exit 1
|
|
fi
|
|
|
|
for filepath in $found; do
|
|
version_dir=$(basename "$(dirname "$filepath")")
|
|
mkdir -p "upload-repo/$version_dir"
|
|
cp "$filepath" "upload-repo/$version_dir/"
|
|
done
|
|
|
|
- name: Calculate and store sha256sums in upload-repo
|
|
run: |
|
|
cd upload-repo
|
|
rm -f sha256sums.txt
|
|
for tarball in */debian-*.tar.bz2; do
|
|
echo "[INFO] Processing: $tarball"
|
|
checksum=$(sha256sum "$tarball" | awk '{print $1}')
|
|
echo "$checksum $tarball" >> sha256sums.txt
|
|
done
|
|
|
|
echo "[INFO] SHA256 contents:"
|
|
cat sha256sums.txt
|
|
|
|
- name: Commit and push files if changed
|
|
id: commit_archives
|
|
run: |
|
|
cd upload-repo
|
|
git config --global user.name "${{ env.GIT_USERNAME }}"
|
|
git config --global user.email "${{ env.GIT_EMAIL }}"
|
|
|
|
if git status --porcelain | grep .; then
|
|
git add **/*.tar.bz2 sha256sums.txt || true
|
|
git commit -m "Update base images and checksum on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
|
git push
|
|
echo "archives_changed=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "[INFO] No changes to commit."
|
|
echo "archives_changed=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
build-and-push-docker-images:
|
|
needs: push-archives-to-repo
|
|
if: needs.push-archives-to-repo.outputs.archives_changed == 'true'
|
|
runs-on: docker-build
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Gitea Registry
|
|
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login gitea.fithwum.tech -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
|
|
|
- name: Build and push Docker images
|
|
run: |
|
|
IMAGE_REGISTRY=gitea.fithwum.tech
|
|
IMAGE_ORG=fithwum
|
|
IMAGE_REPO=debian-base
|
|
|
|
for TAG in $VERSIONS; do
|
|
FULL_IMAGE="${IMAGE_REGISTRY}/${IMAGE_ORG}/${IMAGE_REPO}:${TAG}"
|
|
echo "[INFO] Building and pushing $FULL_IMAGE"
|
|
docker buildx build --platform linux/amd64 --push -t "$FULL_IMAGE" "./$TAG"
|
|
done
|
|
|
|
generate-changelogs:
|
|
needs: build-and-push-docker-images
|
|
runs-on: docker-build
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Clone upload repo
|
|
run: git clone https://${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_TOKEN }}@gitea.fithwum.tech/fithwum/debian-base.git upload-repo
|
|
|
|
- name: Generate per-version changelogs
|
|
run: |
|
|
cd upload-repo
|
|
for version in $VERSIONS; do
|
|
echo "[INFO] Updating changelog for $version"
|
|
|
|
changelog="$version/CHANGES.md"
|
|
mkdir -p "$(dirname "$changelog")"
|
|
touch "$changelog"
|
|
|
|
infofile="$version/build-info.json"
|
|
last_commit=""
|
|
if [ -f "$infofile" ]; then
|
|
last_commit=$(jq -r '.commit' "$infofile")
|
|
fi
|
|
|
|
echo -e "\n## $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$changelog"
|
|
if [ -n "$last_commit" ]; then
|
|
git log "${last_commit}..HEAD" --pretty=format:"- %s (%an)" | head -n 10 >> "$changelog"
|
|
else
|
|
git log -n 10 --pretty=format:"- %s (%an)" >> "$changelog"
|
|
fi
|
|
done
|
|
|
|
- name: Commit and push changelogs if changed
|
|
run: |
|
|
cd upload-repo
|
|
git config user.name "${{ secrets.GIT_USERNAME }}"
|
|
git config user.email "${{ secrets.GIT_EMAIL }}"
|
|
|
|
if git status --porcelain | grep .; then
|
|
git add */CHANGES.md
|
|
git commit -m "Update changelogs on $(date -u +'%Y-%m-%dT%H:%M:%SZ')" --no-verify
|
|
git push
|
|
else
|
|
echo "[INFO] No changelog changes to commit."
|
|
fi
|
|
|
|
generate-build-info:
|
|
needs: generate-changelogs
|
|
runs-on: docker-build
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Clone upload repo
|
|
run: |
|
|
git clone "https://${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_TOKEN }}@gitea.fithwum.tech/fithwum/debian-base.git" upload-repo
|
|
|
|
- name: Copy checksum file into workspace
|
|
run: cp ../sha256sums.txt upload-repo/
|
|
|
|
- name: Generate build-info.json per version
|
|
run: |
|
|
human_size() {
|
|
local b=$1
|
|
local d=''
|
|
local s=0
|
|
local S=(B KB MB GB TB)
|
|
while ((b >= 1024 && s < ${#S[@]}-1)); do
|
|
d=$((b % 1024))
|
|
b=$((b / 1024))
|
|
s=$((s + 1))
|
|
done
|
|
printf "%s%s\n" "$b" "${S[$s]}"
|
|
}
|
|
|
|
cd upload-repo
|
|
for version in $VERSIONS; do
|
|
echo "[INFO] Generating build-info.json for $version"
|
|
mkdir -p "$version"
|
|
infofile="$version/build-info.json"
|
|
|
|
image="gitea.fithwum.tech/fithwum/debian-base:$version"
|
|
|
|
digest=$(docker inspect --format='{{if .RepoDigests}}{{index .RepoDigests 0}}{{else}}unknown{{end}}' "$image" 2>/dev/null || echo "unknown")
|
|
size_bytes=$(docker image inspect "$image" --format='{{.Size}}' 2>/dev/null || echo "0")
|
|
|
|
size_bytes=${size_bytes//[^0-9]/}
|
|
if [[ -z "$size_bytes" ]]; then size_bytes=0; fi
|
|
|
|
size_human=$(human_size "$size_bytes")
|
|
|
|
# Load SHA256 from file if available
|
|
SHA256=$(grep "$version/debian-$version.tar.bz2" ../sha256sums.txt | awk '{print $1}')
|
|
if [[ -z "$SHA256" ]]; then
|
|
SHA256="unknown"
|
|
fi
|
|
|
|
jq -n \
|
|
--arg version "$version" \
|
|
--arg commit "$(git rev-parse HEAD)" \
|
|
--arg build_time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
|
|
--arg image_tag "$image" \
|
|
--arg digest "$digest" \
|
|
--arg image_size "$size_human" \
|
|
--argjson image_size_bytes "$size_bytes" \
|
|
--arg sha256 "$SHA256" \
|
|
'{
|
|
version: $version,
|
|
commit: $commit,
|
|
build_time: $build_time,
|
|
image_tag: $image_tag,
|
|
digest: $digest,
|
|
image_size: $image_size,
|
|
image_size_bytes: $image_size_bytes,
|
|
rootfs_sha256: $sha256
|
|
}' > "$infofile"
|
|
|
|
|
|
- name: Commit and push build-info if changed
|
|
run: |
|
|
cd upload-repo
|
|
git config --global user.name "${{ env.GIT_USERNAME }}"
|
|
git config --global user.email "${{ env.GIT_EMAIL }}"
|
|
|
|
if git status --porcelain | grep .; then
|
|
git add */build-info.json
|
|
git commit -m "Update build-info on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
|
git push
|
|
|
|
# Tag the commit for each version
|
|
for version in $VERSIONS; do
|
|
TAG="build-$version"
|
|
# Delete local tag if exists
|
|
git tag -d "$TAG" 2>/dev/null || true
|
|
# Create tag on current HEAD
|
|
git tag "$TAG"
|
|
# Push tag to remote (force in case tag exists)
|
|
git push origin "$TAG" --force
|
|
done
|
|
else
|
|
echo "[INFO] No build-info changes to commit."
|
|
fi |