커버리지 및 저장소 확대
This commit is contained in:
@@ -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
|
||||
|
||||
30
branch_list
30
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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user