diff --git a/.gitea/workflows/mirror.yml b/.gitea/workflows/mirror.yml index 1ed9879..a11d45a 100644 --- a/.gitea/workflows/mirror.yml +++ b/.gitea/workflows/mirror.yml @@ -8,7 +8,7 @@ on: required: false default: '' schedule: - - cron: '7 17 * * *' # UTC 17:07 == KST 02:07 + - cron: '7 16 * * *' # UTC 16:07 == KST 01:07 jobs: mirror: @@ -95,7 +95,7 @@ jobs: max_api_retry=3 attempt=1 while (( attempt<=max_api_retry )); do - response=$(curl -s -w "\n%{http_code}" -X PATCH -H "Content-Type: application/json" -H "${AUTH_HEADER}" -d "{\"default_branch\":\"main\"}" "${BASE_GITEA_URL}/api/v1/repos/${CENTER_ORG}/${repo_name}") + response=$(curl -s -w "\n%{http_code}" -X PATCH -H "Content-Type: application/json" -H "${AUTH_HEADER}" -d "{\"default_branch\":\"main\"}" "${BASE_GITEA_URL}/api/v1/repos/${CENTER_ORG}/${repo_name}") || response=$'\n000' http_status=$(echo "${response}" | tail -n1) body=$(echo "${response}" | sed '$d') if [[ "${http_status}" == "000" || "${http_status}" =~ ^5 || "${http_status}" == "429" ]]; then @@ -191,7 +191,7 @@ jobs: max_api_retry=3 attempt=1 while (( attempt<=max_api_retry )); do - http_status=$(curl -s -o /dev/null -w "%{http_code}" -H "${AUTH_HEADER}" "${BASE_GITEA_URL}/api/v1/repos/${CENTER_ORG}/${repo_name}") + http_status=$(curl -s -o /dev/null -w "%{http_code}" -H "${AUTH_HEADER}" "${BASE_GITEA_URL}/api/v1/repos/${CENTER_ORG}/${repo_name}") || http_status="000" if [[ "${http_status}" == "000" || "${http_status}" =~ ^5 || "${http_status}" == "429" ]]; then echo "::warning::Repo check HTTP ${http_status} for ${repo_name} (${attempt}/3); retrying in 5s..." sleep 5 @@ -206,7 +206,7 @@ jobs: create_tmp="$(mktemp)" attempt=1 while (( attempt<=max_api_retry )); do - create_status=$(curl -s -o "${create_tmp}" -w "%{http_code}" -X POST -H "Content-Type: application/json" -H "${AUTH_HEADER}" -d "{\"name\":\"${repo_name}\",\"private\":true,\"default_branch\":\"main\"}" "${BASE_GITEA_URL}/api/v1/orgs/${CENTER_ORG}/repos") + create_status=$(curl -s -o "${create_tmp}" -w "%{http_code}" -X POST -H "Content-Type: application/json" -H "${AUTH_HEADER}" -d "{\"name\":\"${repo_name}\",\"private\":true,\"default_branch\":\"main\"}" "${BASE_GITEA_URL}/api/v1/orgs/${CENTER_ORG}/repos") || create_status="000" if [[ "${create_status}" == "000" || "${create_status}" =~ ^5 || "${create_status}" == "429" ]]; then echo "::warning::Repo create HTTP ${create_status} for ${repo_name} (${attempt}/3); retrying in 5s..." sleep 5 @@ -391,3 +391,8 @@ jobs: -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 + + if (( TOTAL_ERROR > 0 )); then + echo "::warning::One or more branches failed (${TOTAL_ERROR})." + exit 1 + fi diff --git a/to-do.md b/to-do.md index 4985d36..31fd3cb 100644 --- a/to-do.md +++ b/to-do.md @@ -30,3 +30,4 @@ 2025-12-17 08:48:00 KST 추가 업데이트: 동일 커밋 건너뛰기 시 모드를 “변경 없음”으로 분리하고 shallow-exclude 실패 시 fetch 로그 tail을 실행 로그에 남기며 폴백 모드를 표시하도록 개선. 2025-12-17 09:38:49 KST 추가 업데이트: Gitea API 오류가 발생해도 전체 작업이 중단되지 않도록 exit 대신 return 처리하여 다음 브랜치로 계속 진행하도록 수정. 2025-12-17 09:50:00 KST 추가 업데이트: Gitea API(조회/생성/기본 브랜치 설정)에 최대 3회 재시도(5초 대기)를 추가해 일시 오류 발생 시에도 작업이 이어지도록 개선, README 반영. +2025-12-18 08:55:36 KST 추가 업데이트: 최근 크론 실행에서 푸시 성공 후 set -e가 미처리된 curl 실패에 반응해 Step이 실패한 사례 대응. Gitea API curl 호출이 실패해도 000 코드로 재시도하도록 가드했고, 전체 처리 후 TOTAL_ERROR>0이면 명시적으로 exit 1, 아니면 0으로 종료하도록 종료 코드를 고정해 불필요한 실패를 방지함.