cron 설정, 최종 요약 메시지 추가

This commit is contained in:
Lectom C Han
2025-12-17 08:29:03 +09:00
parent a2f9b29a95
commit 985600cb2d
3 changed files with 23 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ on:
required: false
default: ''
schedule:
- cron: '24 23 * * *' # Runs every day at 2:07 AM
- cron: '7 17 * * *' # UTC 17:07 == KST 02:07
jobs:
mirror:
@@ -44,10 +44,18 @@ jobs:
ROOT_DIR="$(pwd)"
NOTIFY_WEBHOOK="${NOTIFY_WEBHOOK:-}"
SYNC_TAGS="${SYNC_TAGS:-true}"
TOTAL_SUCCESS=0
TOTAL_SKIP=0
TOTAL_ERROR=0
notify_status() {
local status="$1" repo="$2" branch="$3" mode="$4" start_epoch="$5" extra="${6:-}"
local ts end_epoch duration text payload
case "${status}" in
success) ((TOTAL_SUCCESS++)) ;;
skip) ((TOTAL_SKIP++)) ;;
error) ((TOTAL_ERROR++)) ;;
esac
[[ -z "${NOTIFY_WEBHOOK}" ]] && return
ts=$(TZ=Asia/Seoul date '+%Y-%m-%d %H:%M:%S %Z')
case "${status}" in
@@ -309,3 +317,15 @@ jobs:
process_entry "${branch_name}"
done < branch_list
fi
TOTAL_PROCESSED=$((TOTAL_SUCCESS + TOTAL_SKIP + TOTAL_ERROR))
SUMMARY_TS=$(TZ=Asia/Seoul date '+%Y-%m-%d %H:%M:%S %Z')
SUMMARY_TEXT="브랜치 동기화 완료: 총 ${TOTAL_PROCESSED}개 (성공 ${TOTAL_SUCCESS}, 동일로 건너뜀 ${TOTAL_SKIP}, 오류 ${TOTAL_ERROR}) - ${SUMMARY_TS}"
echo "${SUMMARY_TEXT}"
if [[ -n "${NOTIFY_WEBHOOK}" ]]; then
SUMMARY_PAYLOAD=${SUMMARY_TEXT//\"/\\\"}
curl -sS -i -X POST \
-H "Content-Type: application/json" \
-d "{\"username\":\"Gitea\",\"icon_url\":\"https://gitea.hmac.kr/assets/img/logo.svg\",\"text\":\"${SUMMARY_PAYLOAD}\"}" \
"${NOTIFY_WEBHOOK}" >/dev/null || echo "::warning::Summary notification failed"
fi