You've already forked go-template-container-webserver
auto update workflow
This commit is contained in:
62
update.sh
Executable file
62
update.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
N8N_HOST="https://n8n.bjphoster.com"
|
||||
WEBHOOK_ID="7c3cf611-e700-4bc0-b108-7d6be458dae6"
|
||||
WEBHOOK_URL="${N8N_HOST}/webhook/${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)"
|
||||
|
||||
echo "Fetching repository list from ${WEBHOOK_URL}..."
|
||||
JSON_RESPONSE=$(curl -s -f "${WEBHOOK_URL}")
|
||||
|
||||
echo "Parsing repository URLs..."
|
||||
CLONE_URLS=$(echo "${JSON_RESPONSE}" | jq -r '.clone_url[]?')
|
||||
|
||||
if [ -z "${CLONE_URLS}" ]; then
|
||||
echo "Error: No clone_url found in response or array is empty"
|
||||
echo "Response: ${JSON_RESPONSE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while IFS= read -r clone_url; do
|
||||
if [ -z "${clone_url}" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Processing repository: ${clone_url}"
|
||||
|
||||
repo_name=$(basename "${clone_url}" .git)
|
||||
|
||||
git clone "${clone_url}" "${repo_name}"
|
||||
pushd "${repo_name}"
|
||||
|
||||
TEMPLATE_REMOTE_NAME="template"
|
||||
git remote add "${TEMPLATE_REMOTE_NAME}" "${TEMPLATE_REPO_DIR}"
|
||||
|
||||
git fetch "${TEMPLATE_REMOTE_NAME}" "${TEMPLATE_BRANCH}"
|
||||
|
||||
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
if git merge "${TEMPLATE_REMOTE_NAME}/${TEMPLATE_BRANCH}" \
|
||||
--no-edit \
|
||||
--no-ff \
|
||||
--message "${COMMIT_MESSAGE}"; then
|
||||
echo "Template merge successful for ${repo_name}"
|
||||
git push
|
||||
else
|
||||
echo "Warning: Merge conflicts detected in ${repo_name}"
|
||||
popd
|
||||
continue
|
||||
fi
|
||||
|
||||
popd
|
||||
done <<< "${CLONE_URLS}"
|
||||
|
||||
echo ""
|
||||
echo "All repositories processed successfully!"
|
||||
Reference in New Issue
Block a user