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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
# paths:
|
paths:
|
||||||
# - 'base-image-script/**'
|
- 'base-image-script/**'
|
||||||
schedule:
|
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:
|
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
|
runs-on: docker-build
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source
|
- name: Checkout source
|
||||||
uses: actions/checkout@v3
|
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: |
|
run: |
|
||||||
versions=(buster bullseye bookworm docker-build)
|
rm -rf upload-repo/*/*.tar.bz2
|
||||||
registry="gitea.fithwum.tech"
|
|
||||||
org="fithwum"
|
|
||||||
repo="debian-base"
|
|
||||||
|
|
||||||
for version in "${versions[@]}"; do
|
- name: Copy new archives to upload-repo
|
||||||
echo "[INFO] Building Debian $version rootfs..."
|
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}"
|
for filepath in $found; do
|
||||||
|
version_dir=$(dirname "$filepath")
|
||||||
# Build Docker image with full tag
|
mkdir -p upload-repo/"$version_dir"
|
||||||
docker build --build-arg VERSION=$version -t "$image_tag" .
|
cp "$filepath" upload-repo/"$version_dir"/
|
||||||
|
|
||||||
# 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
|
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: List output archive
|
- name: Commit and push archives if changed
|
||||||
run: |
|
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
|
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
|
if git status --porcelain | grep .; then
|
||||||
echo "[INFO] No changes to commit."
|
git add **/*.tar.bz2
|
||||||
else
|
|
||||||
git commit -m "Update base images on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
git commit -m "Update base images on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||||
git push
|
git push
|
||||||
|
else
|
||||||
|
echo "[INFO] No changes to commit."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build-and-push-docker-images:
|
build-and-push-docker-images:
|
||||||
|
needs: push-archives-to-repo
|
||||||
runs-on: docker-build
|
runs-on: docker-build
|
||||||
needs: build-rootfs-archives
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout source
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set image tags and names
|
- name: Set image tags and names
|
||||||
@@ -91,19 +103,26 @@ jobs:
|
|||||||
IMAGE_REGISTRY=gitea.fithwum.tech
|
IMAGE_REGISTRY=gitea.fithwum.tech
|
||||||
IMAGE_ORG=fithwum
|
IMAGE_ORG=fithwum
|
||||||
IMAGE_REPO=debian-base
|
IMAGE_REPO=debian-base
|
||||||
|
|
||||||
IMAGE_TAGS=(buster bullseye bookworm docker-build)
|
IMAGE_TAGS=(buster bullseye bookworm docker-build)
|
||||||
|
|
||||||
for TAG in "${IMAGE_TAGS[@]}"; do
|
for TAG in "${IMAGE_TAGS[@]}"; do
|
||||||
|
TAG_UPPER=$(echo "$TAG" | tr '[:lower:]' '[:upper:]')
|
||||||
FULL_IMAGE="${IMAGE_REGISTRY}/${IMAGE_ORG}/${IMAGE_REPO}:${TAG}"
|
FULL_IMAGE="${IMAGE_REGISTRY}/${IMAGE_ORG}/${IMAGE_REPO}:${TAG}"
|
||||||
# Use lowercase env var names matching the tag exactly
|
echo "IMAGE_${TAG_UPPER}=${FULL_IMAGE}" >> $GITHUB_ENV
|
||||||
echo "IMAGE_${TAG}=${FULL_IMAGE}" >> $GITHUB_ENV
|
|
||||||
done
|
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
|
- name: Build and push Docker images
|
||||||
run: |
|
run: |
|
||||||
for TAG in buster bullseye bookworm docker-build; do
|
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
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user