백업 레포 내용이 동일하면 Skip

This commit is contained in:
Lectom C Han
2025-12-16 09:44:28 +09:00
parent f6246bc878
commit 4a13289f23
2 changed files with 19 additions and 0 deletions

View File

@@ -52,6 +52,11 @@ jobs:
start)
text="센터Git ${repo} 백업을 ${ts}에 시작합니다. (branch: ${branch}, mode: ${mode})"
;;
skip)
end_epoch=$(date +%s)
duration=$((end_epoch - start_epoch))
text="센터Git ${repo} 백업을 건너뜁니다. (branch: ${branch} -> main, mode: ${mode}, duration: ${duration}s, 시각: ${ts})"
;;
success)
end_epoch=$(date +%s)
duration=$((end_epoch - start_epoch))
@@ -142,6 +147,7 @@ jobs:
notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source branch 없음/비어 있음"
return
fi
branch_commit=$(echo "${branch_ref}" | awk '{print $1}')
# Check if repository exists on Gitea
repo_exists=false
@@ -180,6 +186,17 @@ jobs:
GITEA_HOSTNAME=$(echo "${BASE_GITEA_URL}" | sed -e 's~^https*://~~' -e 's~/$~~')
GITEA_REMOTE="https://${BASE_GITEA_USER}:${BASE_GITEA_TOKEN}@${GITEA_HOSTNAME}/${CENTER_ORG}/${repo_name}.git"
# If target repo exists and refs match, skip heavy operations
if ${repo_exists}; then
target_main_ref=$(git ls-remote "${GITEA_REMOTE}" "refs/heads/main" || true)
target_commit=$(echo "${target_main_ref}" | awk '{print $1}')
if [[ -n "${branch_commit:-}" && -n "${target_commit}" && "${branch_commit}" == "${target_commit}" ]]; then
echo "Target main already at source commit (${branch_commit}). Skipping clone/push."
notify_status "skip" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}"
return
fi
fi
# Create a temporary directory for cloning
CLONE_DIR=$(mktemp -d)
echo "Working directory: ${CLONE_DIR}"

View File

@@ -12,3 +12,5 @@
---
2025-12-16 09:04:36 KST 업데이트: mirror.yml에서 대상 저장소를 `git clone --mirror` 대신 `--bare`로 받도록 변경하여 `fatal: --mirror can't be combined with refspecs` 오류를 제거. 기존 저장소가 있을 때는 Gitea 원격을 bare 클론 후 `source` 리모트를 원본 SSH에 추가하고 브랜치만 fetch → `origin``main`으로 강제 푸시하도록 정리. 새 저장소일 때는 원본을 bare 클론해 `origin``source`로 rename 후 Gitea를 `origin`으로 추가, 같은 fetch→push 동작 수행. 작업 루트 경로를 `ROOT_DIR`에 저장해 fetch/push 실패 시에도 항상 원위치로 돌아가며 임시 디렉터리를 정리하도록 수정.
2025-12-16 09:42:00 KST 업데이트: mirror.yml에 NOTIFY_WEBHOOK 기반 상태 알림(start/success/error, 소요시간 포함) 추가 및 heredoc 제거로 문법 오류 수정. 브랜치명 매핑을 확장해 Develop_Net8_* 접두사는 제거, Develop_/develop_ 접두사는 제거하여 `develop_boxzainer``boxzainer`로 푸시되도록 수정하고, 접두사 없는 `develop` 등은 그대로 사용.
2025-12-16 09:42:00 KST 추가 업데이트: mirror.yml에서 타겟이 존재할 때 `git ls-remote`로 main 커밋을 조회하고 소스 브랜치 커밋과 동일하면 클론/푸시를 건너뛰도록 최적화. 알림에 skip 상태를 추가해 동일 커밋 시 건너뛰는 로그를 남기도록 개선.