커버리지 및 저장소 확대

This commit is contained in:
Lectom C Han
2025-12-15 18:32:43 +09:00
parent d3cd0a8cc2
commit 9e114ee6a1
2 changed files with 58 additions and 32 deletions

View File

@@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
branches:
description: 'Comma-separated list of branches to mirror (e.g., Develop_Net8,Develop_Net8_box). If empty, all branches from branch_list file will be mirrored.'
description: 'Comma-separated list of sourceRepo/branch entries to mirror (e.g., dev_Net8.git/Develop_Net8,dev.git/develop). If empty, all entries from branch_list file will be mirrored.'
required: false
default: ''
schedule:
@@ -38,6 +38,7 @@ jobs:
CENTER_ORG="center_dev"
AUTH_HEADER="Authorization: token ${BASE_GITEA_TOKEN}"
SOURCE_SSH_HOST="engdev@172.16.42.118"
set_default_branch_main() {
local repo_name="$1"
@@ -56,28 +57,46 @@ jobs:
fi
}
process_branch() {
local branch_name
branch_name="$(echo "$1" | xargs)" # trim whitespace
process_entry() {
local entry branch_name source_repo source_repo_url
entry="$(echo "$1" | xargs)" # trim whitespace
if [[ -z "$branch_name" ]]; then
if [[ -z "$entry" ]]; then
return
fi
echo "================================================="
echo "Processing branch: ${branch_name}"
repo_name=""
if [ "${branch_name}" == "Develop_Net8" ]; then
repo_name="base"
elif [[ "${branch_name}" == Develop_Net8_* ]]; then
repo_name="${branch_name#Develop_Net8_}"
else
repo_name="${branch_name}"
if [[ "$entry" != */* ]]; then
echo "::warning::Entry '${entry}' is missing sourceRepo/branch format. Skipping."
return
fi
source_repo="${entry%%/*}"
branch_name="${entry#*/}"
if [[ -z "$source_repo" || -z "$branch_name" ]]; then
echo "::warning::Invalid entry '${entry}'. Skipping."
return
fi
source_repo_url="ssh://${SOURCE_SSH_HOST}/${source_repo}"
echo "================================================="
echo "Processing source: ${source_repo} / branch: ${branch_name}"
repo_name="${branch_name}"
echo "Target repository name: ${repo_name}"
# Skip if the source branch does not exist or is empty
branch_ref="$(git ls-remote --heads "${source_repo_url}" "${branch_name}")" || {
echo "::warning::Failed to query branch '${branch_name}' from source. Skipping."
return
}
if [[ -z "${branch_ref}" ]]; then
echo "::warning::Branch '${branch_name}' does not exist or is empty on source. Skipping."
return
fi
# Check if repository exists on Gitea
repo_exists=false
http_status=$(curl -s -o /dev/null -w "%{http_code}" -H "${AUTH_HEADER}" "${BASE_GITEA_URL}/api/v1/repos/${CENTER_ORG}/${repo_name}")
@@ -106,7 +125,6 @@ jobs:
# Define remote URL's hostname, stripping protocol
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"
SOURCE_REPO="ssh://engdev@172.16.42.118/dev_Net8.git"
# Create a temporary directory for cloning
CLONE_DIR=$(mktemp -d)
@@ -120,7 +138,7 @@ jobs:
return
fi
cd "${CLONE_DIR}"
git remote add source "${SOURCE_REPO}"
git remote add source "${source_repo_url}"
echo "Fetching latest branch '${branch_name}' from source..."
if ! git fetch source "+refs/heads/${branch_name}:refs/heads/${branch_name}"; then
echo "::error::Failed to fetch branch '${branch_name}' from source repo"
@@ -130,8 +148,8 @@ jobs:
fi
else
echo "Cloning source repository for first-time push..."
if ! git clone --mirror "${SOURCE_REPO}" "${CLONE_DIR}"; then
echo "::error::Failed to clone source repository ${SOURCE_REPO}"
if ! git clone --mirror "${source_repo_url}" "${CLONE_DIR}"; then
echo "::error::Failed to clone source repository ${source_repo_url}"
rm -rf "${CLONE_DIR}"
return
fi
@@ -165,11 +183,11 @@ jobs:
for branch in "${branches_to_process[@]}"; do
# Trim whitespace
trimmed_branch=$(echo "$branch" | xargs)
process_branch "${trimmed_branch}"
process_entry "${trimmed_branch}"
done
else
echo "Processing all branches from branch_list file."
while IFS= read -r branch_name || [[ -n "$branch_name" ]]; do
process_branch "${branch_name}"
process_entry "${branch_name}"
done < branch_list
fi