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