You've already forked go-template-container-webserver
maybe fixed merge changes
All checks were successful
Update Child Repos / update (push) Successful in 6s
All checks were successful
Update Child Repos / update (push) Successful in 6s
This commit is contained in:
@@ -10,8 +10,31 @@ CONFLICT_WEBHOOK_URL="${N8N_HOST}/webhook/${CONFLICT_WEBHOOK_ID}"
|
||||
|
||||
TEMPLATE_REPO_DIR=$(pwd)
|
||||
TEMPLATE_BRANCH="main"
|
||||
COMMIT_ID=$(git log HEAD --oneline | awk '{print $1}' | head -n1)
|
||||
COMMIT_MESSAGE="Template updates (commit: $COMMIT_ID)"
|
||||
|
||||
CURRENT_COMMIT_ID=$(git rev-parse HEAD)
|
||||
COMMIT_MESSAGE="Template updates (commit: ${CURRENT_COMMIT_ID:0:7})"
|
||||
|
||||
PREVIOUS_COMMIT_ID=$(git log --format="%H" -n 2 HEAD | tail -n 1)
|
||||
|
||||
if [ "${PREVIOUS_COMMIT_ID}" = "${CURRENT_COMMIT_ID}" ]; then
|
||||
FILES_CHANGED=""
|
||||
else
|
||||
FILES_CHANGED=$(git diff --name-only "${PREVIOUS_COMMIT_ID}" "${CURRENT_COMMIT_ID}" | tr '\n' ' ')
|
||||
fi
|
||||
|
||||
is_file_changed() {
|
||||
local file_to_check="$1"
|
||||
if [ -z "${FILES_CHANGED}" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
for changed_file in ${FILES_CHANGED}; do
|
||||
if [ "${changed_file}" = "${file_to_check}" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
FILES_TO_UPDATE="${FILES_TO_UPDATE:-config.yaml.example
|
||||
deploy.sh
|
||||
@@ -66,6 +89,10 @@ while IFS= read -r clone_url; do
|
||||
conflicted_files=()
|
||||
|
||||
for file in ${FILES_TO_UPDATE}; do
|
||||
if ! is_file_changed "${file}"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! git show "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}:${file}" >/dev/null 2>&1; then
|
||||
continue
|
||||
fi
|
||||
@@ -79,35 +106,8 @@ while IFS= read -r clone_url; do
|
||||
continue
|
||||
fi
|
||||
|
||||
merge_base=$(git merge-base HEAD "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}" 2>/dev/null || true)
|
||||
|
||||
if [ -n "${merge_base}" ] && git show "${merge_base}:${file}" >/dev/null 2>&1; then
|
||||
tmp_base=$(mktemp)
|
||||
tmp_template=$(mktemp)
|
||||
tmp_current=$(mktemp)
|
||||
|
||||
git show "${merge_base}:${file}" > "${tmp_base}" 2>/dev/null
|
||||
echo "${template_content}" > "${tmp_template}"
|
||||
echo "${current_content}" > "${tmp_current}"
|
||||
|
||||
if git merge-file "${tmp_current}" "${tmp_base}" "${tmp_template}" 2>/dev/null; then
|
||||
merged_content=$(cat "${tmp_current}")
|
||||
if [ "${current_content}" != "${merged_content}" ]; then
|
||||
echo "${merged_content}" > "${file}"
|
||||
git add "${file}"
|
||||
files_changed=true
|
||||
echo "Merged updates for ${file} in ${repo_name}"
|
||||
fi
|
||||
else
|
||||
echo "Merge conflict detected in ${repo_name}:${file} - preserving local changes"
|
||||
echo "File ${file} has local changes in ${repo_name} - preserving local changes"
|
||||
conflicted_files+=("${file}")
|
||||
fi
|
||||
|
||||
rm -f "${tmp_base}" "${tmp_template}" "${tmp_current}"
|
||||
else
|
||||
echo "No merge base available for ${file} in ${repo_name} - preserving local changes"
|
||||
conflicted_files+=("${file}")
|
||||
fi
|
||||
else
|
||||
echo "Adding new file ${file} from template to ${repo_name}"
|
||||
mkdir -p "$(dirname "${file}")"
|
||||
|
||||
Reference in New Issue
Block a user