커버리지 및 저장소 확대

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: workflow_dispatch:
inputs: inputs:
branches: 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 required: false
default: '' default: ''
schedule: schedule:
@@ -38,6 +38,7 @@ jobs:
CENTER_ORG="center_dev" CENTER_ORG="center_dev"
AUTH_HEADER="Authorization: token ${BASE_GITEA_TOKEN}" AUTH_HEADER="Authorization: token ${BASE_GITEA_TOKEN}"
SOURCE_SSH_HOST="engdev@172.16.42.118"
set_default_branch_main() { set_default_branch_main() {
local repo_name="$1" local repo_name="$1"
@@ -56,28 +57,46 @@ jobs:
fi fi
} }
process_branch() { process_entry() {
local branch_name local entry branch_name source_repo source_repo_url
branch_name="$(echo "$1" | xargs)" # trim whitespace entry="$(echo "$1" | xargs)" # trim whitespace
if [[ -z "$branch_name" ]]; then if [[ -z "$entry" ]]; then
return return
fi fi
echo "=================================================" if [[ "$entry" != */* ]]; then
echo "Processing branch: ${branch_name}" echo "::warning::Entry '${entry}' is missing sourceRepo/branch format. Skipping."
return
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}"
fi 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}" 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 # Check if repository exists on Gitea
repo_exists=false 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}") 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 # Define remote URL's hostname, stripping protocol
GITEA_HOSTNAME=$(echo "${BASE_GITEA_URL}" | sed -e 's~^https*://~~' -e 's~/$~~') 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" 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 # Create a temporary directory for cloning
CLONE_DIR=$(mktemp -d) CLONE_DIR=$(mktemp -d)
@@ -120,7 +138,7 @@ jobs:
return return
fi fi
cd "${CLONE_DIR}" cd "${CLONE_DIR}"
git remote add source "${SOURCE_REPO}" git remote add source "${source_repo_url}"
echo "Fetching latest branch '${branch_name}' from source..." echo "Fetching latest branch '${branch_name}' from source..."
if ! git fetch source "+refs/heads/${branch_name}:refs/heads/${branch_name}"; then if ! git fetch source "+refs/heads/${branch_name}:refs/heads/${branch_name}"; then
echo "::error::Failed to fetch branch '${branch_name}' from source repo" echo "::error::Failed to fetch branch '${branch_name}' from source repo"
@@ -130,8 +148,8 @@ jobs:
fi fi
else else
echo "Cloning source repository for first-time push..." echo "Cloning source repository for first-time push..."
if ! git clone --mirror "${SOURCE_REPO}" "${CLONE_DIR}"; then if ! git clone --mirror "${source_repo_url}" "${CLONE_DIR}"; then
echo "::error::Failed to clone source repository ${SOURCE_REPO}" echo "::error::Failed to clone source repository ${source_repo_url}"
rm -rf "${CLONE_DIR}" rm -rf "${CLONE_DIR}"
return return
fi fi
@@ -165,11 +183,11 @@ jobs:
for branch in "${branches_to_process[@]}"; do for branch in "${branches_to_process[@]}"; do
# Trim whitespace # Trim whitespace
trimmed_branch=$(echo "$branch" | xargs) trimmed_branch=$(echo "$branch" | xargs)
process_branch "${trimmed_branch}" process_entry "${trimmed_branch}"
done done
else else
echo "Processing all branches from branch_list file." echo "Processing all branches from branch_list file."
while IFS= read -r branch_name || [[ -n "$branch_name" ]]; do while IFS= read -r branch_name || [[ -n "$branch_name" ]]; do
process_branch "${branch_name}" process_entry "${branch_name}"
done < branch_list done < branch_list
fi fi

View File

@@ -1,11 +1,19 @@
Develop_Net8 dev_Net8.git/Develop_Net8
Develop_Net8_box dev_Net8.git/Develop_Net8_bridge
Develop_Net8_bridge dev_Net8.git/Develop_Net8_Graphics
Develop_Net8_Graphics dev_Net8.git/Develop_Net8_Graphics_ModelerUI
Develop_Net8_Graphics_ModelerUI dev_Net8.git/Develop_Net8_heh
Develop_Net8_heh dev_Net8.git/Develop_Net8_Strana
Develop_Net8_Strana dev_Net8.git/Develop_Net8_tunnel
Develop_Net8_tunnel dev_Net8.git/Develop_Net8_wall
Develop_Net8_wall dev_Net8.git/Develop_Net8_way
Develop_Net8_way dev.git/develop
Develop_Net8_way_bridge dev.git/develop_boxzainer
dev.git/develop_boxzainer_demo
dev.git/develop_brizainer
dev.git/develop_heh
dev.git/develop_hmEG
dev.git/develop_hmEG_DotNET_7
dev.git/develop_tunnelzainer
dev.git/develop_wallzainer
dev.git/develop_way_2023