test
Some checks failed
Build and Push Teamspeak Images on Base Image Update / check-for-changes (push) Failing after 6s
Build and Push Teamspeak Images on Base Image Update / build-alpine (push) Has been skipped
Build and Push Teamspeak Images on Base Image Update / build-debian (push) Has been skipped
Build and Push Teamspeak Images on Base Image Update / build-basic (push) Has been skipped
Build and Push Teamspeak Images on Base Image Update / generate-build-info (push) Has been skipped
Build and Push Teamspeak Images on Base Image Update / generate-changelogs (push) Has been skipped
Some checks failed
Build and Push Teamspeak Images on Base Image Update / check-for-changes (push) Failing after 6s
Build and Push Teamspeak Images on Base Image Update / build-alpine (push) Has been skipped
Build and Push Teamspeak Images on Base Image Update / build-debian (push) Has been skipped
Build and Push Teamspeak Images on Base Image Update / build-basic (push) Has been skipped
Build and Push Teamspeak Images on Base Image Update / generate-build-info (push) Has been skipped
Build and Push Teamspeak Images on Base Image Update / generate-changelogs (push) Has been skipped
This commit is contained in:
@@ -23,15 +23,18 @@ jobs:
|
|||||||
should_build_alpine: ${{ steps.check.outputs.should_build_alpine }}
|
should_build_alpine: ${{ steps.check.outputs.should_build_alpine }}
|
||||||
should_build_debian: ${{ steps.check.outputs.should_build_debian }}
|
should_build_debian: ${{ steps.check.outputs.should_build_debian }}
|
||||||
should_build_basic: ${{ steps.check.outputs.should_build_basic }}
|
should_build_basic: ${{ steps.check.outputs.should_build_basic }}
|
||||||
alpine_digest: ${{ steps.get_digest.outputs.alpine_digest }}
|
alpine_digest: ${{ steps.check.outputs.alpine_digest }}
|
||||||
debian_digest: ${{ steps.get_digest.outputs.debian_digest }}
|
debian_digest: ${{ steps.check.outputs.debian_digest }}
|
||||||
basic_digest: ${{ steps.get_digest.outputs.basic_digest }}
|
basic_digest: ${{ steps.check.outputs.basic_digest }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Ensure .cache directory
|
||||||
|
run: mkdir -p .cache
|
||||||
|
|
||||||
- name: Pull latest base images
|
- name: Pull latest base images
|
||||||
run: |
|
run: |
|
||||||
docker pull alpine:latest
|
docker pull alpine:latest
|
||||||
@@ -42,11 +45,39 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
alpine_digest=$(docker inspect --format='{{index .RepoDigests 0}}' alpine:latest || echo "unknown")
|
alpine_digest=$(docker inspect --format='{{index .RepoDigests 0}}' alpine:latest || echo "unknown")
|
||||||
debian_digest=$(docker inspect --format='{{index .RepoDigests 0}}' gitea.fithwum.tech/${{ secrets.GIT_USERNAME }}/debian-base:bookworm || echo "unknown")
|
debian_digest=$(docker inspect --format='{{index .RepoDigests 0}}' gitea.fithwum.tech/${{ secrets.GIT_USERNAME }}/debian-base:bookworm || echo "unknown")
|
||||||
basic_digest=$(docker inspect --format='{{index .RepoDigests 0}}' gitea.fithwum.tech/${{ secrets.GIT_USERNAME }}/debian-base:bookworm || echo "unknown")
|
basic_digest=$debian_digest # assuming basic uses same debian-base image
|
||||||
|
|
||||||
|
echo "$alpine_digest" > .cache/alpine-base.digest
|
||||||
|
echo "$debian_digest" > .cache/debian-base.digest
|
||||||
|
echo "$basic_digest" > .cache/basic-base.digest
|
||||||
|
|
||||||
echo "alpine_digest=$alpine_digest" >> $GITHUB_OUTPUT
|
echo "alpine_digest=$alpine_digest" >> $GITHUB_OUTPUT
|
||||||
echo "debian_digest=$debian_digest" >> $GITHUB_OUTPUT
|
echo "debian_digest=$debian_digest" >> $GITHUB_OUTPUT
|
||||||
echo "basic_digest=$basic_digest" >> $GITHUB_OUTPUT
|
echo "basic_digest=$basic_digest" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Commit and push updated base digests if changed
|
||||||
|
run: |
|
||||||
|
git config user.name "${{ secrets.GIT_USERNAME }}"
|
||||||
|
git config user.email "${{ secrets.GIT_EMAIL }}"
|
||||||
|
|
||||||
|
changes=false
|
||||||
|
for file in .cache/*-base.digest; do
|
||||||
|
if git diff --quiet "$file"; then
|
||||||
|
echo "[INFO] No changes in $file"
|
||||||
|
else
|
||||||
|
echo "[INFO] Changes detected in $file"
|
||||||
|
changes=true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$changes" = true ]; then
|
||||||
|
git add .cache/*-base.digest
|
||||||
|
git commit -m "Update base image digests ($(date -u +'%Y-%m-%dT%H:%M:%SZ'))"
|
||||||
|
git push
|
||||||
|
else
|
||||||
|
echo "[INFO] No base digest changes to commit."
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Compare digests and detect changes
|
- name: Compare digests and detect changes
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
@@ -66,7 +97,7 @@ jobs:
|
|||||||
base_changed=true
|
base_changed=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Detect changes in variant folder
|
# Detect changes in variant folder compared to origin/main
|
||||||
code_changed=$(git diff --name-only origin/main | grep "^$variant/" || true)
|
code_changed=$(git diff --name-only origin/main | grep "^$variant/" || true)
|
||||||
if [[ -n "$code_changed" ]]; then
|
if [[ -n "$code_changed" ]]; then
|
||||||
code_changed=true
|
code_changed=true
|
||||||
@@ -80,12 +111,14 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "should_build_${variant}=$should_build" >> $GITHUB_OUTPUT
|
echo "should_build_${variant}=$should_build" >> $GITHUB_OUTPUT
|
||||||
|
echo "${variant}_digest=$new_digest" >> $GITHUB_OUTPUT
|
||||||
}
|
}
|
||||||
|
|
||||||
check_variant "alpine" "${{ steps.get_digest.outputs.alpine_digest }}"
|
check_variant "alpine" "${{ steps.get_digest.outputs.alpine_digest }}"
|
||||||
check_variant "debian" "${{ steps.get_digest.outputs.debian_digest }}"
|
check_variant "debian" "${{ steps.get_digest.outputs.debian_digest }}"
|
||||||
check_variant "basic" "${{ steps.get_digest.outputs.basic_digest }}"
|
check_variant "basic" "${{ steps.get_digest.outputs.basic_digest }}"
|
||||||
|
|
||||||
|
|
||||||
build-alpine:
|
build-alpine:
|
||||||
needs: check-for-changes
|
needs: check-for-changes
|
||||||
if: needs.check-for-changes.outputs.should_build_alpine == 'true'
|
if: needs.check-for-changes.outputs.should_build_alpine == 'true'
|
||||||
@@ -168,20 +201,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Prepare temporary build-info workspace
|
|
||||||
run: mkdir -p upload-repo
|
|
||||||
|
|
||||||
- name: Clone Minecraft repo
|
|
||||||
run: |
|
|
||||||
GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}"
|
|
||||||
git clone --depth=1 "https://${{ secrets.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/teamspeak-server.git" upload-repo
|
|
||||||
cd upload-repo
|
|
||||||
|
|
||||||
- name: Generate build-info.json only for updated variants
|
- name: Generate build-info.json only for updated variants
|
||||||
env:
|
env:
|
||||||
IMAGE_REGISTRY: ${{ env.IMAGE_REGISTRY }}
|
IMAGE_REGISTRY: ${{ env.IMAGE_REGISTRY }}
|
||||||
IMAGE_ORG: ${{ env.IMAGE_ORG }}
|
IMAGE_ORG: ${{ env.IMAGE_ORG }}
|
||||||
IMAGE_REPO_TS: ${{ env.IMAGE_REPO_TS }}
|
IMAGE_REPO_TS: ${{ env.IMAGE_REPO_TS }}
|
||||||
|
ALPINE_DIGEST: ${{ needs.check-for-changes.outputs.alpine_digest }}
|
||||||
|
DEBIAN_DIGEST: ${{ needs.check-for-changes.outputs.debian_digest }}
|
||||||
|
BASIC_DIGEST: ${{ needs.check-for-changes.outputs.basic_digest }}
|
||||||
CACHE_DIR: ${{ env.CACHE_DIR }}
|
CACHE_DIR: ${{ env.CACHE_DIR }}
|
||||||
run: |
|
run: |
|
||||||
human_size() {
|
human_size() {
|
||||||
@@ -208,35 +235,20 @@ jobs:
|
|||||||
versions+=("basic")
|
versions+=("basic")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find alpine debian basic -type f -name build-info.json -exec rm -v {} +
|
|
||||||
|
|
||||||
for version in "${versions[@]}"; do
|
for version in "${versions[@]}"; do
|
||||||
echo "[INFO] Generating build-info.json for $version"
|
echo "[INFO] Generating build-info.json for $version"
|
||||||
image="${IMAGE_REGISTRY}/${IMAGE_ORG}/${IMAGE_REPO_TS}:${version}"
|
mkdir -p "$version"
|
||||||
infofile="$version/build-info.json"
|
infofile="$version/build-info.json"
|
||||||
mkdir -p "$(dirname "$infofile")"
|
image="${IMAGE_REGISTRY}/${IMAGE_ORG}/${IMAGE_REPO_TS}:$version"
|
||||||
|
|
||||||
if ! docker pull "$image"; then
|
echo "[DEBUG] Inspecting image: $image"
|
||||||
echo "[WARN] Failed to pull $image — setting fields to unknown/0"
|
|
||||||
digest="unknown"
|
|
||||||
size_bytes=0
|
|
||||||
else
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
docker pull "$image" || echo "[WARN] Failed to pull $image"
|
||||||
|
docker images --digests | grep "$version" || echo "[WARN] Image not listed locally"
|
||||||
|
digest=$(docker inspect --format='{{index .RepoDigests 0}}' "$(docker images --format '{{.Repository}}:{{.Tag}}' | grep "${IMAGE_REPO_TS}:$version" | head -n1)" 2>/dev/null || echo "unknown")
|
||||||
|
size_bytes=$(docker inspect --format='{{.Size}}' "$(docker images --format '{{.Repository}}:{{.Tag}}' | grep "${IMAGE_REPO_TS}:$version" | head -n1)" 2>/dev/null || echo "0")
|
||||||
size_human=$(human_size "$size_bytes")
|
size_human=$(human_size "$size_bytes")
|
||||||
|
|
||||||
# base digest logic
|
|
||||||
base_digest="unknown"
|
|
||||||
if [ "$version" = "alpine" ]; then
|
|
||||||
base_digest=$(docker inspect --format='{{index .RepoDigests 0}}' alpine:latest 2>/dev/null || echo "unknown")
|
|
||||||
elif [ "$version" = "debian" ] || [ "$version" = "basic" ]; then
|
|
||||||
base_digest=$(docker inspect --format='{{index .RepoDigests 0}}' gitea.fithwum.tech/${{ secrets.GIT_USERNAME }}/debian-base:bookworm 2>/dev/null || echo "unknown")
|
|
||||||
fi
|
|
||||||
|
|
||||||
jq -n \
|
jq -n \
|
||||||
--arg version "$version" \
|
--arg version "$version" \
|
||||||
--arg commit "$(git rev-parse HEAD)" \
|
--arg commit "$(git rev-parse HEAD)" \
|
||||||
@@ -245,7 +257,6 @@ jobs:
|
|||||||
--arg digest "$digest" \
|
--arg digest "$digest" \
|
||||||
--arg image_size "$size_human" \
|
--arg image_size "$size_human" \
|
||||||
--argjson image_size_bytes "$size_bytes" \
|
--argjson image_size_bytes "$size_bytes" \
|
||||||
--arg base_digest "$base_digest" \
|
|
||||||
'{
|
'{
|
||||||
version: $version,
|
version: $version,
|
||||||
commit: $commit,
|
commit: $commit,
|
||||||
@@ -254,28 +265,15 @@ jobs:
|
|||||||
digest: $digest,
|
digest: $digest,
|
||||||
image_size: $image_size,
|
image_size: $image_size,
|
||||||
image_size_bytes: $image_size_bytes,
|
image_size_bytes: $image_size_bytes,
|
||||||
base_digest: $base_digest
|
|
||||||
}' > "$infofile"
|
}' > "$infofile"
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Copy build-info to repo
|
|
||||||
run: |
|
|
||||||
for version in alpine debian basic; do
|
|
||||||
if [ -f "$version/build-info.json" ]; then
|
|
||||||
mkdir -p "upload-repo/$version"
|
|
||||||
cp "$version/build-info.json" "upload-repo/$version/"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Commit and push build-info if changed
|
- name: Commit and push build-info if changed
|
||||||
working-directory: upload-repo
|
|
||||||
run: |
|
run: |
|
||||||
git config user.name "${{ secrets.GIT_USERNAME }}"
|
git config user.name "${{ secrets.GIT_USERNAME }}"
|
||||||
git config user.email "${{ secrets.GIT_EMAIL }}"
|
git config user.email "${{ secrets.GIT_EMAIL }}"
|
||||||
|
if git status --porcelain | grep .; then
|
||||||
git add */build-info.json
|
git add */build-info.json
|
||||||
|
|
||||||
if ! git diff --cached --quiet; then
|
|
||||||
git commit -m "Update build-info on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
git commit -m "Update build-info on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||||
git push
|
git push
|
||||||
|
|
||||||
@@ -289,20 +287,8 @@ jobs:
|
|||||||
echo "[INFO] No build-info changes to commit."
|
echo "[INFO] No build-info changes to commit."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ls -l */build-info.json || echo "❌ build-info not written"
|
ls -l basic/build-info.json || echo "❌ build-info not written"
|
||||||
for version in alpine debian basic; do
|
cat basic/build-info.json || echo "❌ empty build-info"
|
||||||
echo "$version build-info.json"
|
|
||||||
cat "$version/build-info.json" || echo "❌ empty build-info for $version"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Show generated build-info
|
|
||||||
run: |
|
|
||||||
for version in alpine debian basic; do
|
|
||||||
echo "::group::$version build-info.json"
|
|
||||||
ls -l "$version/build-info.json" || echo "❌ missing"
|
|
||||||
cat "$version/build-info.json" || echo "❌ empty"
|
|
||||||
echo "::endgroup::"
|
|
||||||
done
|
|
||||||
|
|
||||||
generate-changelogs:
|
generate-changelogs:
|
||||||
needs: generate-build-info
|
needs: generate-build-info
|
||||||
|
|||||||
Reference in New Issue
Block a user