From 9e114ee6a17c0405574fe00d27a9553a1859a426 Mon Sep 17 00:00:00 2001 From: Lectom C Han Date: Mon, 15 Dec 2025 18:32:43 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BB=A4=EB=B2=84=EB=A6=AC=EC=A7=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A0=80=EC=9E=A5=EC=86=8C=20=ED=99=95=EB=8C=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/mirror.yml | 60 ++++++++++++++++++++++++------------- branch_list | 30 ++++++++++++------- 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/.gitea/workflows/mirror.yml b/.gitea/workflows/mirror.yml index afb7c47..e9b29a2 100644 --- a/.gitea/workflows/mirror.yml +++ b/.gitea/workflows/mirror.yml @@ -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 diff --git a/branch_list b/branch_list index aa995c2..3d357de 100644 --- a/branch_list +++ b/branch_list @@ -1,11 +1,19 @@ -Develop_Net8 -Develop_Net8_box -Develop_Net8_bridge -Develop_Net8_Graphics -Develop_Net8_Graphics_ModelerUI -Develop_Net8_heh -Develop_Net8_Strana -Develop_Net8_tunnel -Develop_Net8_wall -Develop_Net8_way -Develop_Net8_way_bridge \ No newline at end of file +dev_Net8.git/Develop_Net8 +dev_Net8.git/Develop_Net8_bridge +dev_Net8.git/Develop_Net8_Graphics +dev_Net8.git/Develop_Net8_Graphics_ModelerUI +dev_Net8.git/Develop_Net8_heh +dev_Net8.git/Develop_Net8_Strana +dev_Net8.git/Develop_Net8_tunnel +dev_Net8.git/Develop_Net8_wall +dev_Net8.git/Develop_Net8_way +dev.git/develop +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