test
All checks were successful
Build and Push Teamspeak Images on Base Image Update / check-for-changes (push) Successful in 16s
Build and Push Teamspeak Images on Base Image Update / build-alpine (push) Successful in 9s
Build and Push Teamspeak Images on Base Image Update / generate-changelogs (push) Successful in 8s
Build and Push Teamspeak Images on Base Image Update / build-debian (push) Successful in 9s
Build and Push Teamspeak Images on Base Image Update / generate-build-info (push) Successful in 5s

This commit is contained in:
2025-07-10 14:36:33 -07:00
parent d56174a136
commit a075ab032d

View File

@@ -44,7 +44,6 @@ jobs:
run: |
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")
echo "alpine_digest=$alpine_digest" >> $GITHUB_OUTPUT
echo "debian_digest=$debian_digest" >> $GITHUB_OUTPUT
@@ -83,8 +82,6 @@ jobs:
echo "should_build_${variant}=$should_build" >> $GITHUB_OUTPUT
}
git fetch origin main
check_variant "alpine" "${{ steps.get_digest.outputs.alpine_digest }}"
check_variant "debian" "${{ steps.get_digest.outputs.debian_digest }}"
@@ -151,15 +148,12 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Clone Teamspeak repo
run: |
git clone https://${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_TOKEN }}@gitea.fithwum.tech/fithwum/teamspeak-server.git upload-repo
with:
fetch-depth: 0
- name: Generate changelogs only for updated variants
run: |
cd upload-repo
versions=()
if [[ "${{ needs.check-for-changes.outputs.should_build_alpine }}" == "true" ]]; then
versions+=("alpine")
fi
@@ -169,7 +163,6 @@ jobs:
for version in "${versions[@]}"; do
echo "[INFO] Updating changelog for $version"
changelog="$version/CHANGES.md"
mkdir -p "$(dirname "$changelog")"
touch "$changelog"
@@ -180,20 +173,25 @@ jobs:
last_commit=$(jq -r '.commit' "$infofile")
fi
# Check if last_commit exists in history, fallback to last 10 commits if not
if ! git cat-file -e "${last_commit}^{commit}" 2>/dev/null; then
echo "[WARN] Last commit from build-info.json not found, using last 10 commits"
last_commit=""
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"
git log "${last_commit}..HEAD" --pretty=format:"- %s (%an)" --no-merges --invert-grep --grep="Update changelogs on" | head -n 10 >> "$changelog"
else
git log -n 10 --pretty=format:"- %s (%an)" >> "$changelog"
git log -n 10 --pretty=format:"- %s (%an)" --no-merges --invert-grep --grep="Update changelogs on" >> "$changelog"
fi
done
- name: Commit and push changelogs
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
@@ -213,10 +211,8 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Clone Teamspeak repo
run: |
git clone https://${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_TOKEN }}@gitea.fithwum.tech/fithwum/teamspeak-server.git upload-repo
with:
fetch-depth: 0
- name: Generate build-info.json only for updated variants
env:
@@ -225,7 +221,6 @@ jobs:
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 }}
CACHE_DIR: ${{ env.CACHE_DIR }}
run: |
human_size() {
local b=$1
@@ -240,12 +235,6 @@ jobs:
printf "%s%s\n" "$b" "${S[$s]}"
}
cd upload-repo
declare -A digests
digests[alpine]="${ALPINE_DIGEST}"
digests[debian]="${DEBIAN_DIGEST}"
versions=()
[[ "${{ needs.check-for-changes.outputs.should_build_alpine }}" == "true" ]] && versions+=("alpine")
[[ "${{ needs.check-for-changes.outputs.should_build_debian }}" == "true" ]] && versions+=("debian")
@@ -256,17 +245,16 @@ jobs:
infofile="$version/build-info.json"
image="${IMAGE_REGISTRY}/${IMAGE_ORG}/${IMAGE_REPO_TS}:$version"
# get digest from metadata file instead of docker inspect
metafile="../${CACHE_DIR}/metadata-$version.json"
digest="unknown"
if [ -f "$metafile" ]; then
digest=$(jq -r '."containerimage.digest"' "$metafile" || echo "unknown")
fi
digest=$(docker inspect --format='{{index .RepoDigests 0}}' "$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]/}
size_human=$(human_size "$size_bytes")
base_digest="${digests[$version]:-unknown}"
base_digest=""
if [ "$version" = "alpine" ]; then
base_digest="$ALPINE_DIGEST"
elif [ "$version" = "debian" ]; then
base_digest="$DEBIAN_DIGEST"
fi
jq -n \
--arg version "$version" \
@@ -291,10 +279,8 @@ jobs:
- name: Commit and push build-info 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 */build-info.json
git commit -m "Update build-info on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
@@ -308,4 +294,4 @@ jobs:
done
else
echo "[INFO] No build-info changes to commit."
fi
fi