test
All checks were successful
Build and Push Minecraft Docker Images on Debian-base update / poll-debian-base-and-detect-changes (push) Successful in 10s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push fabric (push) Has been skipped
Build and Push Minecraft Docker Images on Debian-base update / Build and Push testing (push) Has been skipped
Build and Push Minecraft Docker Images on Debian-base update / Build and Push vanilla (push) Has been skipped
All checks were successful
Build and Push Minecraft Docker Images on Debian-base update / poll-debian-base-and-detect-changes (push) Successful in 10s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push fabric (push) Has been skipped
Build and Push Minecraft Docker Images on Debian-base update / Build and Push testing (push) Has been skipped
Build and Push Minecraft Docker Images on Debian-base update / Build and Push vanilla (push) Has been skipped
This commit is contained in:
@@ -5,7 +5,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/*.yml'
|
- '.gitea/workflows/*.yml'
|
||||||
- '**/Dockerfile'
|
- '**/Dockerfile'
|
||||||
- '**/*.sh'
|
- '**/*.sh'
|
||||||
- '!**/CHANGES.md'
|
- '!**/CHANGES.md'
|
||||||
@@ -187,91 +187,102 @@ generate-changelogs:
|
|||||||
echo "[INFO] No changelog changes to commit."
|
echo "[INFO] No changelog changes to commit."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
generate-build-info:
|
generate-build-info:
|
||||||
needs: generate-changelogs
|
needs: generate-changelogs
|
||||||
runs-on: doc-docker-build2
|
runs-on: doc-docker-build2
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
version: [vanilla, testing, fabric]
|
version: [vanilla, testing, fabric]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Clone Minecraft repo (with retries)
|
- name: Clone Minecraft repo (with retries)
|
||||||
run: |
|
run: |
|
||||||
GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}"
|
GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}"
|
||||||
for i in {1..5}; do
|
for i in {1..5}; do
|
||||||
git clone "https://${{ secrets.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/minecraft.git" upload-repo && break
|
git clone "https://${{ secrets.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/minecraft.git" upload-repo && break
|
||||||
echo "[WARN] Clone attempt $i failed. Retrying in 10s..."
|
echo "[WARN] Clone attempt $i failed. Retrying in 10s..."
|
||||||
sleep 10
|
sleep 10
|
||||||
|
done
|
||||||
|
if [ ! -d upload-repo ]; then
|
||||||
|
echo "[ERROR] Failed to clone Minecraft repo after retries."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Generate build-info.json
|
||||||
|
run: |
|
||||||
|
human_size() {
|
||||||
|
local b=$1 d='' s=0 S=(B KB MB GB TB)
|
||||||
|
while ((b >= 1024 && s < ${#S[@]}-1)); do
|
||||||
|
d=$((b % 1024)); b=$((b / 1024)); s=$((s + 1))
|
||||||
done
|
done
|
||||||
if [ ! -d upload-repo ]; then
|
printf "%s%s\n" "$b" "${S[$s]}"
|
||||||
echo "[ERROR] Failed to clone Minecraft repo after retries."
|
}
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Generate build-info.json
|
cd upload-repo
|
||||||
run: |
|
mkdir -p "${{ matrix.version }}"
|
||||||
human_size() {
|
infofile="${{ matrix.version }}/build-info.json"
|
||||||
local b=$1 d='' s=0 S=(B KB MB GB TB)
|
image="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_ORG }}/${{ env.IMAGE_REPO_MINECRAFT }}:${{ matrix.version }}"
|
||||||
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
|
if ! docker pull "$image"; then
|
||||||
mkdir -p "${{ matrix.version }}"
|
echo "[WARN] Failed to pull $image — setting fields to unknown/0"
|
||||||
infofile="${{ matrix.version }}/build-info.json"
|
digest="unknown"
|
||||||
image="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_ORG }}/${{ env.IMAGE_REPO_MINECRAFT }}:${{ matrix.version }}"
|
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
|
||||||
|
|
||||||
if ! docker pull "$image"; then
|
size_human=$(human_size "$size_bytes")
|
||||||
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
|
|
||||||
|
|
||||||
size_human=$(human_size "$size_bytes")
|
jq -n \
|
||||||
|
--arg version "${{ matrix.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"
|
||||||
|
|
||||||
jq -n \
|
echo "[INFO] Generated $infofile:"
|
||||||
--arg version "${{ matrix.version }}" \
|
cat "$infofile"
|
||||||
--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"
|
|
||||||
|
|
||||||
- name: Commit and push build-info
|
- name: Git status debug
|
||||||
run: |
|
run: |
|
||||||
cd upload-repo
|
cd upload-repo
|
||||||
git config user.name "${{ secrets.GIT_USERNAME }}"
|
echo "[DEBUG] Git status before commit:"
|
||||||
git config user.email "${{ secrets.GIT_EMAIL }}"
|
git status
|
||||||
if git status --porcelain | grep .; then
|
echo "[DEBUG] Git diff:"
|
||||||
git add "${{ matrix.version }}/build-info.json"
|
git diff "${{ matrix.version }}/build-info.json" || true
|
||||||
git commit -m "Update build-info on $(date -u +'%Y-%m-%dT%H:%M:%SZ')" || true
|
|
||||||
git push
|
|
||||||
|
|
||||||
# Optional: push lightweight tag for this build
|
- name: Commit and push build-info
|
||||||
TAG="build-${{ matrix.version }}"
|
run: |
|
||||||
git tag -d "$TAG" 2>/dev/null || true
|
cd upload-repo
|
||||||
git tag "$TAG"
|
git config user.name "${{ secrets.GIT_USERNAME }}"
|
||||||
git push origin "$TAG" --force
|
git config user.email "${{ secrets.GIT_EMAIL }}"
|
||||||
else
|
|
||||||
echo "[INFO] No build-info changes to commit."
|
if git status --porcelain | grep .; then
|
||||||
fi
|
git add "${{ matrix.version }}/build-info.json"
|
||||||
|
git commit -m "Update build-info for ${{ matrix.version }} on $(date -u +'%Y-%m-%dT%H:%M:%SZ')" || true
|
||||||
|
git push
|
||||||
|
|
||||||
|
TAG="build-${{ matrix.version }}"
|
||||||
|
git tag -d "$TAG" 2>/dev/null || true
|
||||||
|
git tag "$TAG"
|
||||||
|
git push origin "$TAG" --force
|
||||||
|
else
|
||||||
|
echo "[INFO] No build-info changes to commit."
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user