log test
Some checks failed
Build and Push Teamspeak Images on Base Image Update / check-base-images-and-build (push) Successful in 12s
Build and Push Teamspeak Images on Base Image Update / generate-build-info (push) Has been cancelled
Build and Push Teamspeak Images on Base Image Update / generate-changelogs (push) Has been cancelled
Some checks failed
Build and Push Teamspeak Images on Base Image Update / check-base-images-and-build (push) Successful in 12s
Build and Push Teamspeak Images on Base Image Update / generate-build-info (push) Has been cancelled
Build and Push Teamspeak Images on Base Image Update / generate-changelogs (push) Has been cancelled
This commit is contained in:
@@ -102,7 +102,139 @@ jobs:
|
|||||||
echo "[INFO] Building $IMAGE"
|
echo "[INFO] Building $IMAGE"
|
||||||
docker buildx build --platform linux/amd64 --push -t "$IMAGE" ./basic
|
docker buildx build --platform linux/amd64 --push -t "$IMAGE" ./basic
|
||||||
|
|
||||||
|
generate-changelogs:
|
||||||
|
needs: check-base-images-and-build
|
||||||
|
runs-on: docker-build
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: Generate per-version changelogs
|
||||||
|
run: |
|
||||||
|
cd upload-repo
|
||||||
|
for version in alpine basic debian; do
|
||||||
|
echo "[INFO] Updating changelog for $version"
|
||||||
|
|
||||||
|
changelog="$version/CHANGES.md"
|
||||||
|
mkdir -p "$(dirname "$changelog")"
|
||||||
|
touch "$changelog"
|
||||||
|
|
||||||
|
infofile="$version/build-info.json"
|
||||||
|
last_commit=""
|
||||||
|
if [ -f "$infofile" ]; then
|
||||||
|
last_commit=$(jq -r '.commit' "$infofile")
|
||||||
|
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"
|
||||||
|
else
|
||||||
|
git log -n 10 --pretty=format:"- %s (%an)" >> "$changelog"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Commit and push changelogs 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 */CHANGES.md
|
||||||
|
git commit -m "Update changelogs on $(date -u +'%Y-%m-%dT%H:%M:%SZ')" --no-verify
|
||||||
|
git push
|
||||||
|
else
|
||||||
|
echo "[INFO] No changelog changes to commit."
|
||||||
|
fi
|
||||||
|
|
||||||
|
generate-build-info:
|
||||||
|
needs: generate-changelogs
|
||||||
|
runs-on: docker-build
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: Generate build-info.json per version
|
||||||
|
run: |
|
||||||
|
human_size() {
|
||||||
|
local b=$1
|
||||||
|
local d=''
|
||||||
|
local s=0
|
||||||
|
local S=(B KB MB GB TB)
|
||||||
|
while ((b >= 1024 && s < ${#S[@]}-1)); do
|
||||||
|
d=$((b % 1024))
|
||||||
|
b=$((b / 1024))
|
||||||
|
s=$((s + 1))
|
||||||
|
done
|
||||||
|
printf "%s%s\n" "$b" "${S[$s]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
cd upload-repo
|
||||||
|
for version in alpine basic debian; do
|
||||||
|
echo "[INFO] Generating build-info.json for $version"
|
||||||
|
mkdir -p "$version"
|
||||||
|
infofile="$version/build-info.json"
|
||||||
|
|
||||||
|
image="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_ORG }}/${{ env.IMAGE_REPO_TS }}:$version"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
size_human=$(human_size "$size_bytes")
|
||||||
|
|
||||||
|
jq -n \
|
||||||
|
--arg version "$version" \
|
||||||
|
--arg commit "$(git rev-parse HEAD)" \
|
||||||
|
--arg build_time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
|
||||||
|
--arg image_tag "$image" \
|
||||||
|
--arg digest "$digest" \
|
||||||
|
--arg image_size "$size_human" \
|
||||||
|
--argjson image_size_bytes "$size_bytes" \
|
||||||
|
'{
|
||||||
|
version: $version,
|
||||||
|
commit: $commit,
|
||||||
|
build_time: $build_time,
|
||||||
|
image_tag: $image_tag,
|
||||||
|
digest: $digest,
|
||||||
|
image_size: $image_size,
|
||||||
|
image_size_bytes: $image_size_bytes
|
||||||
|
}' > "$infofile"
|
||||||
|
done
|
||||||
|
|
||||||
|
- 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')"
|
||||||
|
git push
|
||||||
|
|
||||||
|
# Tag the commit for each version
|
||||||
|
for version in alpine basic debian; do
|
||||||
|
TAG="build-$version"
|
||||||
|
git tag -d "$TAG" 2>/dev/null || true
|
||||||
|
git tag "$TAG"
|
||||||
|
git push origin "$TAG" --force
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "[INFO] No build-info changes to commit."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user