fix: remove image cleanup step, Volcano Engine CR doesn't support API delete
All checks were successful
Build and Deploy Log Center / build-and-deploy (push) Successful in 5s
All checks were successful
Build and Deploy Log Center / build-and-deploy (push) Successful in 5s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
749cddf561
commit
58ee345895
@ -123,50 +123,8 @@ jobs:
|
|||||||
kubectl rollout restart deployment/log-center-web
|
kubectl rollout restart deployment/log-center-web
|
||||||
} 2>&1 | tee /tmp/deploy.log
|
} 2>&1 | tee /tmp/deploy.log
|
||||||
|
|
||||||
# ==================== 清理旧镜像(保留最近5个版本) ====================
|
|
||||||
|
|
||||||
- name: Clean old images
|
|
||||||
if: success()
|
|
||||||
run: |
|
|
||||||
KEEP=5
|
|
||||||
CR="${{ secrets.CR_SERVER }}"
|
|
||||||
ORG="${{ env.CR_ORG }}"
|
|
||||||
AUTH="${{ secrets.CR_USERNAME }}:${{ secrets.CR_PASSWORD }}"
|
|
||||||
|
|
||||||
for REPO in log-center-api log-center-web k8s-pod-monitor; do
|
|
||||||
echo "Cleaning ${ORG}/${REPO}..."
|
|
||||||
|
|
||||||
# 获取 Harbor token
|
|
||||||
TOKEN=$(curl -s -u "${AUTH}" "https://${CR}/service/token?service=harbor-registry&scope=repository:${ORG}/${REPO}:pull,delete" | \
|
|
||||||
python3 -c "import sys,json; print(json.load(sys.stdin).get('token',''))" 2>/dev/null)
|
|
||||||
|
|
||||||
# 列出所有标签,排序后取要删除的
|
|
||||||
TAGS=$(curl -s -H "Authorization: Bearer ${TOKEN}" "https://${CR}/v2/${ORG}/${REPO}/tags/list" | \
|
|
||||||
python3 -c "
|
|
||||||
import sys,json
|
|
||||||
try:
|
|
||||||
data = json.load(sys.stdin)
|
|
||||||
tags = [t for t in data.get('tags',[]) if t != 'latest']
|
|
||||||
tags.sort(reverse=True)
|
|
||||||
for t in tags[${KEEP}:]:
|
|
||||||
print(t)
|
|
||||||
except: pass
|
|
||||||
" 2>/dev/null)
|
|
||||||
|
|
||||||
for TAG in $TAGS; do
|
|
||||||
DIGEST=$(curl -s -H "Authorization: Bearer ${TOKEN}" \
|
|
||||||
-H 'Accept: application/vnd.docker.distribution.manifest.v2+json' \
|
|
||||||
"https://${CR}/v2/${ORG}/${REPO}/manifests/${TAG}" -o /dev/null -D - | \
|
|
||||||
grep -i docker-content-digest | awk '{print $2}' | tr -d '\r')
|
|
||||||
if [ -n "$DIGEST" ]; then
|
|
||||||
curl -s -X DELETE -H "Authorization: Bearer ${TOKEN}" \
|
|
||||||
"https://${CR}/v2/${ORG}/${REPO}/manifests/${DIGEST}"
|
|
||||||
echo " Deleted: ${TAG}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
# ==================== CI/CD 错误上报 ====================
|
# ==================== CI/CD 错误上报 ====================
|
||||||
|
# 注:火山引擎 CR 小微版不支持 API 删除镜像,需在控制台手动清理旧版本
|
||||||
|
|
||||||
- name: Report failure to Log Center
|
- name: Report failure to Log Center
|
||||||
if: failure()
|
if: failure()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user