From 1af38d18e722841a989deab0b9b5c44696630630 Mon Sep 17 00:00:00 2001 From: Lectom C Han Date: Tue, 16 Dec 2025 09:04:13 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A0=88=ED=8F=AC=20=ED=83=80=EC=9E=85?= =?UTF-8?q?=EC=9D=84=20mirror=EC=97=90=EC=84=9C=20bare=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD.=20=EA=B8=B0=EB=B3=B8=20=EB=B8=8C=EB=A0=8C?= =?UTF-8?q?=EC=B9=98=20Main=20=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/mirror.yml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.gitea/workflows/mirror.yml b/.gitea/workflows/mirror.yml index f383d30..c190bfe 100644 --- a/.gitea/workflows/mirror.yml +++ b/.gitea/workflows/mirror.yml @@ -39,6 +39,7 @@ jobs: CENTER_ORG="center_dev" AUTH_HEADER="Authorization: token ${BASE_GITEA_TOKEN}" SOURCE_SSH_HOST="engdev@172.16.42.118" + ROOT_DIR="$(pwd)" set_default_branch_main() { local repo_name="$1" @@ -136,43 +137,44 @@ jobs: echo "Working directory: ${CLONE_DIR}" if ${repo_exists}; then - echo "Cloning existing target repository for update..." - if ! git clone --mirror "${GITEA_REMOTE}" "${CLONE_DIR}"; then + echo "Cloning existing target repository for update (bare)..." + if ! git clone --bare "${GITEA_REMOTE}" "${CLONE_DIR}"; then echo "::error::Failed to clone existing target repository ${GITEA_REMOTE}" rm -rf "${CLONE_DIR}" return fi cd "${CLONE_DIR}" 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" - cd .. - rm -rf "${CLONE_DIR}" - return - fi else - echo "Cloning source repository for first-time push..." - if ! git clone --mirror "${source_repo_url}" "${CLONE_DIR}"; then + echo "Cloning source repository for first-time push (bare)..." + if ! git clone --bare "${source_repo_url}" "${CLONE_DIR}"; then echo "::error::Failed to clone source repository ${source_repo_url}" rm -rf "${CLONE_DIR}" return fi cd "${CLONE_DIR}" + git remote rename origin source + git remote add origin "${GITEA_REMOTE}" fi - git remote set-url origin "${GITEA_REMOTE}" + 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" + cd "${ROOT_DIR}" + rm -rf "${CLONE_DIR}" + return + fi echo "Pushing '${branch_name}' to Gitea repository '${repo_name}'..." if ! git push --force origin "refs/heads/${branch_name}:refs/heads/main"; then echo "::error::Failed to push branch '${branch_name}' to target repository" - cd .. + cd "${ROOT_DIR}" rm -rf "${CLONE_DIR}" return fi # Cleanup - cd .. + cd "${ROOT_DIR}" rm -rf "${CLONE_DIR}" echo "Successfully mirrored ${branch_name} to center_dev/${repo_name}"