gitea API 응답 오류 포함 중단하지 않을 작업 wrapping
Some checks failed
Git Repository Mirroring / mirror (push) Failing after 30s

This commit is contained in:
Lectom C Han
2025-12-18 09:38:09 +09:00
parent 7e17aa1b85
commit d4d6065198
2 changed files with 10 additions and 4 deletions

View File

@@ -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