HH-707: skip existing image versions (#3)
Build and publish image / image (push) Successful in 13s

This commit was merged in pull request #3.
This commit is contained in:
2026-08-26 19:30:30 +08:00
parent 72b5e78e26
commit 311fd97275
3 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
CHROME_VERSION=148.0.7778.215 ./scripts/build.sh my-registry/fingerprint-chromium
```
脚本从上游 GitHub Release 解析唯一的 Linux x86_64 压缩包,镜像 tag 使用完整 Chrome 版本。设置 `PUSH=true` 时,构建完成后推送镜像
脚本从上游 GitHub Release 解析唯一的 Linux x86_64 压缩包,镜像 tag 使用完整 Chrome 版本。设置 `PUSH=true` 时,若仓库中不存在该版本标签则构建并推送,否则跳过
## 运行
+5
View File
@@ -20,6 +20,11 @@ asset_url="$(jq -er --arg version "$version" '
' <<<"$release")"
tag="$image:$version"
if [[ "${PUSH:-false}" == "true" ]] && docker manifest inspect "$tag" >/dev/null 2>&1; then
printf 'Image %s already exists; skipping build and push\n' "$tag"
exit 0
fi
docker build --pull --platform linux/amd64 \
--build-arg "CHROME_VERSION=$version" \
--build-arg "CHROME_URL=$asset_url" \
+12
View File
@@ -18,3 +18,15 @@ grep -q 'OCI_SOURCE: https://git.ipao.vip/rogee/fingerprint-chromium' .gitea/wor
grep -q '/link/fingerprint-chromium' .gitea/workflows/publish.yml
grep -q "repository.full_name // empty" .gitea/workflows/publish.yml
test "$(grep -c 'Authorization: token \$REGISTRY_TOKEN' .gitea/workflows/publish.yml)" -eq 3
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
printf '%s\n' '#!/bin/sh' 'printf '\''{"tag_name":"1.2.3.4","assets":[{"name":"ungoogled-chromium-1.2.3.4-test-x86_64_linux.tar.xz","browser_download_url":"https://example.invalid/chromium.tar.xz"}]}'\''' > "$tmpdir/curl"
printf '%s\n' '#!/bin/sh' 'printf '\''%s\n'\'' "$*" >> "$DOCKER_LOG"' '[ "$1 $2" = "manifest inspect" ]' > "$tmpdir/docker"
chmod +x "$tmpdir/curl" "$tmpdir/docker"
docker_log="$tmpdir/docker.log"
DOCKER_LOG="$docker_log" OCI_REVISION=test PUSH=true PATH="$tmpdir:$PATH" \
./scripts/build.sh registry.example/fingerprint-chromium > "$tmpdir/output"
test "$(cat "$docker_log")" = "manifest inspect registry.example/fingerprint-chromium:1.2.3.4"
grep -q 'skipping build and push' "$tmpdir/output"