추가 캐시 생성 삭제
This commit is contained in:
@@ -8,7 +8,7 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 17 * * *' # UTC 17:00 == KST 02:00
|
- cron: '0 17 * * 1-5' # UTC 17:00 == KST 02:00, Mon-Fri only
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
backup:
|
backup:
|
||||||
@@ -57,8 +57,6 @@ jobs:
|
|||||||
echo "::warning::TARGET_SEED_DEPTH(${TARGET_SEED_DEPTH}) is invalid; resetting to 50"
|
echo "::warning::TARGET_SEED_DEPTH(${TARGET_SEED_DEPTH}) is invalid; resetting to 50"
|
||||||
TARGET_SEED_DEPTH=50
|
TARGET_SEED_DEPTH=50
|
||||||
fi
|
fi
|
||||||
CACHE_BASE="${ROOT_DIR}/.cache_sources"
|
|
||||||
mkdir -p "${CACHE_BASE}"
|
|
||||||
TOTAL_SUCCESS=0
|
TOTAL_SUCCESS=0
|
||||||
TOTAL_SKIP=0
|
TOTAL_SKIP=0
|
||||||
TOTAL_ERROR=0
|
TOTAL_ERROR=0
|
||||||
@@ -247,49 +245,14 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prepare_cache() {
|
|
||||||
local source_repo="$1" cache_dir="${CACHE_BASE}/${source_repo//\//_}.git"
|
|
||||||
if [[ ! -d "${cache_dir}" ]]; then
|
|
||||||
echo "Initializing local cache for ${source_repo} at ${cache_dir}"
|
|
||||||
if ! git clone --mirror "${SOURCE_SSH_HOST}:${source_repo}" "${cache_dir}"; then
|
|
||||||
echo "::warning::Failed to clone cache for ${source_repo} (${SOURCE_SSH_HOST}:${source_repo})"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Refreshing cache for ${source_repo}"
|
|
||||||
if ! git -C "${cache_dir}" fetch --prune --prune-tags origin "+refs/*:refs/*"; then
|
|
||||||
echo "::warning::Failed to refresh cache for ${source_repo} (${SOURCE_SSH_HOST}:${source_repo})"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
SOURCE_CACHE_PATH["${source_repo}"]="${cache_dir}"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Preparing per-source caches..."
|
|
||||||
for source_repo in "${!SOURCE_REPOS[@]}"; do
|
|
||||||
prepare_cache "${source_repo}" || echo "::warning::Cache unavailable for ${source_repo}; will fallback to direct fetch"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Step 1) 소스 브랜치 해시 스캔"
|
echo "Step 1) 소스 브랜치 해시 스캔"
|
||||||
for source_repo in "${!SOURCE_REPOS[@]}"; do
|
for source_repo in "${!SOURCE_REPOS[@]}"; do
|
||||||
cache_dir="${SOURCE_CACHE_PATH[${source_repo}]:-}"
|
|
||||||
source_repo_url="${SOURCE_SSH_HOST}:${source_repo}"
|
source_repo_url="${SOURCE_SSH_HOST}:${source_repo}"
|
||||||
if [[ -n "${cache_dir}" && -d "${cache_dir}" ]]; then
|
|
||||||
echo " - using cache: ${cache_dir}"
|
|
||||||
if ! remote_output=$(git -C "${cache_dir}" for-each-ref --format='%(objectname)\t%(refname)' 'refs/heads/*'); then
|
|
||||||
echo "::warning::Failed to read heads from cache ${cache_dir}; falling back to remote ${source_repo_url}."
|
|
||||||
remote_output=$(git ls-remote --heads "${source_repo_url}") || {
|
|
||||||
echo "::warning::Failed to ls-remote ${source_repo_url}. Entries for this repo may fail."
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo " - ${source_repo_url}"
|
echo " - ${source_repo_url}"
|
||||||
if ! remote_output=$(git ls-remote --heads "${source_repo_url}"); then
|
if ! remote_output=$(git ls-remote --heads "${source_repo_url}"); then
|
||||||
echo "::warning::Failed to ls-remote ${source_repo_url}. Entries for this repo may fail."
|
echo "::warning::Failed to ls-remote ${source_repo_url}. Entries for this repo may fail."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
if [[ -z "${remote_output}" ]]; then
|
if [[ -z "${remote_output}" ]]; then
|
||||||
echo "::warning::No branches found for ${source_repo_url}"
|
echo "::warning::No branches found for ${source_repo_url}"
|
||||||
continue
|
continue
|
||||||
@@ -449,9 +412,9 @@ jobs:
|
|||||||
|
|
||||||
CLONE_DIR=$(mktemp -d)
|
CLONE_DIR=$(mktemp -d)
|
||||||
echo "Working directory: ${CLONE_DIR}"
|
echo "Working directory: ${CLONE_DIR}"
|
||||||
|
SOURCE_FETCH_REMOTE="${SOURCE_SSH_HOST}:${source_repo}"
|
||||||
if ${just_created}; then
|
if ${just_created}; then
|
||||||
echo "Target repo newly created; cloning source branch for initial push..."
|
echo "Target repo newly created; cloning source branch for initial push..."
|
||||||
SOURCE_FETCH_REMOTE="${SOURCE_CACHE_PATH[${source_repo}]:-${SOURCE_SSH_HOST}:${source_repo}}"
|
|
||||||
if ! git clone --bare --no-tags --single-branch --branch "${branch_name}" "${SOURCE_FETCH_REMOTE}" "${CLONE_DIR}"; then
|
if ! git clone --bare --no-tags --single-branch --branch "${branch_name}" "${SOURCE_FETCH_REMOTE}" "${CLONE_DIR}"; then
|
||||||
echo "::error::Failed to clone source repository ${SOURCE_FETCH_REMOTE}"
|
echo "::error::Failed to clone source repository ${SOURCE_FETCH_REMOTE}"
|
||||||
notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source clone 실패" "${heads_detail}"
|
notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source clone 실패" "${heads_detail}"
|
||||||
@@ -475,7 +438,6 @@ jobs:
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
git remote add origin "${GITEA_REMOTE}"
|
git remote add origin "${GITEA_REMOTE}"
|
||||||
SOURCE_FETCH_REMOTE="${SOURCE_CACHE_PATH[${source_repo}]:-${SOURCE_SSH_HOST}:${source_repo}}"
|
|
||||||
git remote add source "${SOURCE_FETCH_REMOTE}"
|
git remote add source "${SOURCE_FETCH_REMOTE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user