test
This commit is contained in:
@@ -1,88 +1,100 @@
|
||||
name: Build and Upload Multiple Debian RootFS Versions
|
||||
name: Build, Upload RootFS, and Push Docker Images
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# paths:
|
||||
# - 'base-image-script/**'
|
||||
paths:
|
||||
- 'base-image-script/**'
|
||||
schedule:
|
||||
- cron: '0 12 * * 0' # Sunday at noon UTC
|
||||
- cron: '0 12 * * 0' # Sundays 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 }}
|
||||
|
||||
jobs:
|
||||
build-debian-variants:
|
||||
build-rootfs-archives:
|
||||
runs-on: docker-build
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
version: [buster, bullseye, bookworm, docker-build]
|
||||
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build Docker image for ${{ matrix.version }}
|
||||
run: |
|
||||
docker build \
|
||||
--build-arg VERSION=${{ matrix.version }} \
|
||||
-t fithwum/debian-${{ matrix.version }}-base .
|
||||
|
||||
- name: Run rootfs builder (pt1 script) for ${{ matrix.version }}
|
||||
run: |
|
||||
docker run --rm --privileged \
|
||||
-v "$(pwd)":/output \
|
||||
fithwum/debian-${{ matrix.version }}-base \
|
||||
bash base-image-script/debian-${{ matrix.version }}_pt1.sh
|
||||
|
||||
- name: List output archives for ${{ matrix.version }}
|
||||
run: |
|
||||
echo "[INFO] Looking for tarballs in workspace..."
|
||||
find . -name '*.tar.bz2' -ls
|
||||
|
||||
push-archives-to-repo:
|
||||
needs: build-rootfs-archives
|
||||
runs-on: docker-build
|
||||
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Build all Debian rootfs versions sequentially
|
||||
- name: Clone upload repo
|
||||
run: git clone "${{ env.REPO_URL }}" upload-repo
|
||||
|
||||
- name: Clean old archives in upload-repo
|
||||
run: |
|
||||
versions=(buster bullseye bookworm docker-build)
|
||||
registry="gitea.fithwum.tech"
|
||||
org="fithwum"
|
||||
repo="debian-base"
|
||||
rm -rf upload-repo/*/*.tar.bz2
|
||||
|
||||
for version in "${versions[@]}"; do
|
||||
echo "[INFO] Building Debian $version rootfs..."
|
||||
- name: Copy new archives to upload-repo
|
||||
run: |
|
||||
found=$(find . -name '*.tar.bz2')
|
||||
if [ -z "$found" ]; then
|
||||
echo "[WARNING] No .tar.bz2 archive found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
image_tag="${registry}/${org}/${repo}:${version}"
|
||||
|
||||
# Build Docker image with full tag
|
||||
docker build --build-arg VERSION=$version -t "$image_tag" .
|
||||
|
||||
# Run the pt1.sh script inside the container to build rootfs
|
||||
docker run --rm --privileged \
|
||||
-v "$(pwd)":/output \
|
||||
"$image_tag" \
|
||||
bash base-image-script/debian-${version}_pt1.sh
|
||||
for filepath in $found; do
|
||||
version_dir=$(dirname "$filepath")
|
||||
mkdir -p upload-repo/"$version_dir"
|
||||
cp "$filepath" upload-repo/"$version_dir"/
|
||||
done
|
||||
|
||||
- name: List output archive
|
||||
- name: Commit and push archives if changed
|
||||
run: |
|
||||
echo "[INFO] Looking for tarballs in workspace..."
|
||||
find . -name '*.tar.bz2' -ls
|
||||
|
||||
- name: Clone and push to Gitea repo
|
||||
env:
|
||||
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
|
||||
GIT_EMAIL: ${{ secrets.GIT_EMAIL }}
|
||||
REPO_URL: ${{ secrets.REPO_URL }}
|
||||
run: |
|
||||
git config --global user.name "$GIT_USERNAME"
|
||||
git config --global user.email "$GIT_EMAIL"
|
||||
|
||||
git clone "$REPO_URL" upload-repo
|
||||
|
||||
# Remove all old tarballs from upload-repo to avoid clutter
|
||||
find upload-repo -name '*.tar.bz2' -type f -delete
|
||||
|
||||
# Copy all new tarballs from workspace into upload-repo preserving folder structure
|
||||
find . -name '*.tar.bz2' -exec bash -c '
|
||||
for filepath; do
|
||||
dir=$(dirname "$filepath")
|
||||
mkdir -p "upload-repo/$dir"
|
||||
cp "$filepath" "upload-repo/$dir/"
|
||||
done
|
||||
' bash {} +
|
||||
|
||||
cd upload-repo
|
||||
git add '**/*.tar.bz2'
|
||||
git config --global user.name "${{ env.GIT_USERNAME }}"
|
||||
git config --global user.email "${{ env.GIT_EMAIL }}"
|
||||
|
||||
if git diff --cached --quiet; then
|
||||
echo "[INFO] No changes to commit."
|
||||
else
|
||||
if git status --porcelain | grep .; then
|
||||
git add **/*.tar.bz2
|
||||
git commit -m "Update base images on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
git push
|
||||
else
|
||||
echo "[INFO] No changes to commit."
|
||||
fi
|
||||
|
||||
build-and-push-docker-images:
|
||||
needs: push-archives-to-repo
|
||||
runs-on: docker-build
|
||||
needs: build-rootfs-archives
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set image tags and names
|
||||
@@ -91,19 +103,26 @@ jobs:
|
||||
IMAGE_REGISTRY=gitea.fithwum.tech
|
||||
IMAGE_ORG=fithwum
|
||||
IMAGE_REPO=debian-base
|
||||
|
||||
IMAGE_TAGS=(buster bullseye bookworm docker-build)
|
||||
|
||||
for TAG in "${IMAGE_TAGS[@]}"; do
|
||||
TAG_UPPER=$(echo "$TAG" | tr '[:lower:]' '[:upper:]')
|
||||
FULL_IMAGE="${IMAGE_REGISTRY}/${IMAGE_ORG}/${IMAGE_REPO}:${TAG}"
|
||||
# Use lowercase env var names matching the tag exactly
|
||||
echo "IMAGE_${TAG}=${FULL_IMAGE}" >> $GITHUB_ENV
|
||||
echo "IMAGE_${TAG_UPPER}=${FULL_IMAGE}" >> $GITHUB_ENV
|
||||
done
|
||||
|
||||
- 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: |
|
||||
for TAG in buster bullseye bookworm docker-build; do
|
||||
docker buildx build --platform linux/amd64 --push -t "${{ env['IMAGE_' + TAG] }}" "./${TAG}"
|
||||
TAG_UPPER=$(echo "$TAG" | tr '[:lower:]' '[:upper:]')
|
||||
IMAGE_VAR="IMAGE_${TAG_UPPER}"
|
||||
docker buildx build --platform linux/amd64 --push -t "${{ env[IMAGE_VAR] }}" "./${TAG}"
|
||||
done
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user