chore(ci): preflight migration validation before deploy
TaxBaik CI/CD / build-and-deploy (push) Failing after 3m47s

This commit is contained in:
2026-07-02 14:12:23 +09:00
parent f68c968aed
commit 3f486d9fe9
3 changed files with 74 additions and 552 deletions
+12 -1
View File
@@ -78,6 +78,9 @@ jobs:
- name: Copy migrations
run: mkdir -p ./publish/db && cp -r db/migrations ./publish/db/ || true
- name: Validate migration version uniqueness
run: bash scripts/validate_migrations.sh db/migrations
- name: Generate build info
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
@@ -109,6 +112,9 @@ jobs:
- name: Package artifact
run: |
cp deploy_gb.sh ./publish/deploy_gb.sh
mkdir -p ./publish/scripts
cp scripts/validate_migrations.sh ./publish/scripts/validate_migrations.sh
chmod +x ./publish/scripts/validate_migrations.sh
tar -czf taxbaik_deploy.tgz -C ./publish .
echo "✓ Package: $(du -sh taxbaik_deploy.tgz | cut -f1)"
@@ -175,7 +181,12 @@ jobs:
test -s "\$DEPLOY_DIR/proxy/TaxBaik.Proxy.dll" \
|| { echo "FATAL: TaxBaik.Proxy.dll 없음" >&2; exit 1; }
echo "--- [3/4] Green-Blue 배포 실행 ---"
echo "--- [3/5] 마이그레이션 사전 검증 ---"
test -x "\$DEPLOY_DIR/scripts/validate_migrations.sh" \
|| { echo "FATAL: validate_migrations.sh 없음" >&2; exit 1; }
"\$DEPLOY_DIR/scripts/validate_migrations.sh" "\$DEPLOY_DIR/db/migrations" "postgresql://taxbaik:taxbaik123@localhost:5432/taxbaikdb"
echo "--- [4/5] Green-Blue 배포 실행 ---"
chmod +x "\$DEPLOY_DIR/deploy_gb.sh"
"\$DEPLOY_DIR/deploy_gb.sh" "\$DEPLOY_DIR"
-551
View File
@@ -1,551 +0,0 @@
-- V025: Add 9 new blog posts with correct SQL structure
-- All posts follow BLOG_TEMPLATE.md guidelines: 3-step structure, accuracy principle, list format
INSERT INTO blog_posts (title, content, slug, category_id, is_published, seo_title, seo_description, tags, created_at, updated_at) VALUES
-- 1. 프리랜서가 놓친 경비 5가지
(
'프리랜서가 놓친 경비 5가지 - 이것도 인정될까요?',
$$# 5
"프리랜서인데 경비로 인정되는 게 뭐고 안 되는 게 뭐죠?"
. 34 .
1
:
- : ,
- : ,
- :
- : ,
- : ,
.
2
?
- (: 60% )
-
?
-
- ( )
- ( )
?
- : ()
- : ( )
- : ( )
50% ?
- 2025 30~40%
- 50%
3
:
- /
-
-
-
: 34
$$,
'freelancer-expenses',
1,
true,
'Freelancer Expenses - Tax Deduction Guide',
'5 common expenses freelancers overlook, with tax law basis (소득세법 제34조)',
'프리랜서,경비,필요경비,소득세,세무',
NOW(),
NOW()
),
-- 2. 월세 신고하는 방법
(
'월세 신고하는 방법 - 환급받을 수 있는 금액이 있습니다',
$$#
"월세를 낼 때 세금 환급이 있다던데 정말인가요?"
592 . .
1
(2025 ):
- : 750
- : ,
- : 10% ( 75 )
( 60 ):
- : 720
- : 72
2
?
- :
- : ? ? ?
- ?
?
- vs : ?
- ? ?
- ? ?
2 ?
- 2023 2025
- ? 5
3
:
-
- vs
- /
-
: 592
$$,
'monthly-rent-tax-credit',
1,
true,
'Monthly Rent Tax Credit Guide',
'How to claim rental tax deduction (월세세액공제) under Income Tax Act Article 59-2',
'월세,세액공제,환급,소득세',
NOW(),
NOW()
),
-- 3. 자녀 증여세 계산하기
(
'자녀 증여세 계산하기 - 기초공제를 모르면 손해봅니다',
$$#
"자녀에게 돈을 주면 세금을 내야 하나요?"
13 . 0.
1
(2025 ):
- 1 5,000 (10)
- : 2,000 (10)
( 1, ):
- 5,000 = 0
- 6,000 = 1,000
:
- 10
- 2015 1,000 + 2025 4,000 = 500 × 10
2
10 ?
- 10
- 9 11
-
?
- 5,000
-
- ? vs
?
- 10~50% ( )
- 1,000 10%
-
3
:
-
-
-
-
: 13
$$,
'gift-tax-calculation',
1,
true,
'Gift Tax for Children Calculation',
'How to calculate inheritance and gift tax with basic deduction (상속세및증여세법 제13조)',
'증여세,자녀,기초공제,상속세',
NOW(),
NOW()
),
-- 4. 사업자 등록 타이밍
(
'사업자 등록 타이밍 - 너무 빨라도, 늦어도 손해입니다',
$$#
"언제 사업자등록을 해야 세금을 절약할 수 있나요?"
2 .
1
:
- 20
- (10%)
:
-
-
:
- 1 1 , 1 20 = OK
- 1 1 , 2 15 = +
2
?
- 500
- 3
-
?
- ?
- ( )
?
- : (, )
- : 100
- :
3
:
-
-
-
-
: 2
$$,
'business-registration-timing',
1,
true,
'Business Registration Timing Guide',
'When to register business for tax optimization (소득세법 제2조)',
'사업자등록,사업소득,세무,등록시기',
NOW(),
NOW()
),
-- 5. 소상공인 간단 기장
(
'소상공인 간단 기장 - 엑셀 + 영수증으로 충분합니다',
$$#
"복식부기는 너무 복잡한데, 정말 간편장부로 가능한가요?"
29 .
1
:
- 8,000
- ,
:
-
-
- ( )
-
:
-
-
-
2
?
- 365
-
-
?
-
- : ( % )
- ( vs )
?
-
-
-
3
:
-
-
- /
-
: 29
$$,
'small-business-bookkeeping',
1,
true,
'Simple Bookkeeping for Small Business',
'Easy accounting for small business owners under Income Tax Act Article 29',
'소상공인,간편장부,기장,세무',
NOW(),
NOW()
),
-- 6. 스마트스토어 판매자 세무
(
'스마트스토어 판매자 세무 - 플랫폼 수입도 세금이 필요합니다',
$$#
"온라인에서 판매한 수입도 신고해야 하나요?"
20 .
1
:
- 100 :
- 100 :
:
- ( )
- ( )
- ()
:
-
-
-
-
2
?
- :
- :
-
?
- :
- : ? ( )
-
vs ?
-
-
-
3
:
-
- /
-
-
: 20 /
$$,
'smartstore-seller-tax',
1,
true,
'Online Seller Tax Guide',
'Tax reporting for online marketplace sellers (소득세법 제20조)',
'스마트스토어,온라인판매,사업소득,세무',
NOW(),
NOW()
),
-- 7. 부가가치세 신고 기한
(
'부가가치세 신고 기한 - 2일만 늦어도 가산세입니다',
$$#
"부가가치세는 언제까지 신고해야 하나요?"
25 .
1
(2025):
- 1 (1~4): 5 25
- 2 (5~8): 9 25
:
- ( )
:
- 8,000 :
- 8,000 :
2
/ ?
- /
- :
-
?
-
-
-
?
- ,
-
-
3
:
-
- /
-
-
: 25
$$,
'vat-reporting-deadline',
1,
true,
'Value Added Tax Reporting Deadline',
'VAT filing deadline and calculation (부가가치세법 제25조)',
'부가가치세,신고기한,세무',
NOW(),
NOW()
),
-- 8. 종합소득세 신고 완벽 가이드
(
'종합소득세 신고 완벽 가이드 - 5월 신고로 연간 세금 결정됩니다',
$$#
"종합소득세는 무엇이고, 정말 모두 신고해야 하나요?"
19 .
1
:
- (, )
- ()
- ( )
- ( )
- ( )
:
- 4,000
:
- 5 31
:
-
-
-
2
?
- , ,
-
-
?
- , ,
- ( )
-
?
- 6~45% ()
-
-
3
:
-
-
-
-
: 19
$$,
'comprehensive-income-tax-guide',
1,
true,
'Comprehensive Income Tax Filing Guide',
'Complete guide to filing comprehensive income tax (종합소득세) (소득세법 제19조)',
'종합소득세,신고,공제,소득세',
NOW(),
NOW()
),
-- 9. 연말정산 환급 최대화
(
'연말정산 환급 최대화 - 놓친 공제 하나가 수십만 원입니다',
$$#
"연말정산으로 환금을 받으려면 뭘 꼭 챙겨야 하나요?"
163 .
1
(2025):
- : 1 150
- : + 900
- : 750
- :
- : 25 15%
:
- 200 (200-250) × 15% = 0
- 300 (300-250) × 15% = 7.5
2
?
-
- (, )
-
-
?
-
- ?
- ? ( )
?
- : ( )
- :
- :
3
:
-
-
- (, )
-
: 163
$$,
'year-end-tax-settlement',
1,
true,
'Year-End Tax Settlement Refund Maximization',
'How to maximize tax refund in year-end adjustment (연말정산) (소득세법 제163조)',
'연말정산,환금,공제,세액공제',
NOW(),
NOW()
);
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -euo pipefail
MIGRATION_DIR="${1:-db/migrations}"
DB_CONNECTION_STRING="${2:-}"
if [ ! -d "$MIGRATION_DIR" ]; then
echo "Migration directory not found: $MIGRATION_DIR" >&2
exit 1
fi
mapfile -t files < <(find "$MIGRATION_DIR" -maxdepth 1 -type f -name 'V*.sql' | sort)
if [ "${#files[@]}" -eq 0 ]; then
echo "No migration files found in $MIGRATION_DIR" >&2
exit 1
fi
declare -A seen_versions=()
duplicate_found=0
for file in "${files[@]}"; do
name="$(basename "$file")"
version="${name#V}"
version="${version%%__*}"
if [ -n "${seen_versions[$version]:-}" ]; then
echo "Duplicate migration version detected: V$version" >&2
echo " - ${seen_versions[$version]}" >&2
echo " - $file" >&2
duplicate_found=1
else
seen_versions["$version"]="$file"
fi
done
if [ "$duplicate_found" -ne 0 ]; then
exit 1
fi
if [ -z "$DB_CONNECTION_STRING" ]; then
echo "Duplicate version check passed."
exit 0
fi
if ! command -v psql >/dev/null 2>&1; then
echo "psql is required for database dry-run validation." >&2
exit 1
fi
for file in "${files[@]}"; do
name="$(basename "$file")"
version="${name#V}"
version="${version%%__*}"
echo "Dry-run migration V$version: $name"
psql "$DB_CONNECTION_STRING" -v ON_ERROR_STOP=1 <<PSQL
BEGIN;
\\i $file
ROLLBACK;
PSQL
done
echo "Migration dry-run validation passed."