Skip to content

Commit 0924c1e

Browse files
committed
fix(ci): Notion 동기화 중단·배포 미트리거 복구 [skip-notion]
server-sync.sh: pull 전 커밋 안 된 로컬 변경을 stash로 치운다. 파일 하나가 git pull --rebase를 영구히 막아 2026-07-21~08-11 42회 연속 동기화 실패가 발생했다. stash 보존이라 작업 유실은 없다. crontab 주기 주석도 실제값(6시간)으로 정정. monthly-translate.yml / merge-develop.yml: GITHUB_TOKEN으로 push한 커밋은 deploy.yml(on: push)을 트리거하지 못한다(워크플로 재귀 방지). workflow_dispatch는 예외이므로 push 성공 시 gh workflow run으로 배포를 명시 호출한다. 8/1 EN 번역 커밋이 배포되지 않은 원인.
1 parent a8835d7 commit 0924c1e

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

.github/workflows/merge-develop.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
permissions:
1212
contents: write
13+
actions: write # deploy.yml 수동 트리거용
1314

1415
jobs:
1516
merge:
@@ -61,6 +62,7 @@ jobs:
6162
run: npm run build
6263

6364
- name: develop → main 머지
65+
id: merge
6466
if: steps.diff.outputs.has_changes == 'true'
6567
run: |
6668
git stash
@@ -89,3 +91,11 @@ jobs:
8991
git add -A
9092
git commit -m "chore: develop → main 머지 (sync-json 충돌 자동 해소) [skip-notion]"
9193
git push origin main
94+
95+
# GITHUB_TOKEN push 는 deploy.yml(on: push)을 트리거하지 못한다 (워크플로 재귀 방지).
96+
# workflow_dispatch 는 예외라 명시 호출로 배포를 잇는다.
97+
- name: Trigger deploy
98+
if: steps.merge.outcome == 'success' && steps.diff.outputs.has_changes == 'true'
99+
env:
100+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
run: gh workflow run deploy.yml --ref main

.github/workflows/monthly-translate.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
permissions:
1212
contents: write
13+
actions: write # deploy.yml 수동 트리거용
1314

1415
steps:
1516
- uses: actions/checkout@v4
@@ -30,11 +31,25 @@ jobs:
3031
run: python3 scripts/translate_to_en.py
3132

3233
- name: Commit translated files
34+
id: commit
3335
run: |
3436
git config user.name "github-actions[bot]"
3537
git config user.email "github-actions[bot]@users.noreply.github.com"
3638
git add i18n/en/ .notion-translate-hashes.json
37-
git diff --cached --quiet && echo "번역 변경 없음" && exit 0
39+
if git diff --cached --quiet; then
40+
echo "번역 변경 없음"
41+
echo "pushed=false" >> $GITHUB_OUTPUT
42+
exit 0
43+
fi
3844
git commit -m "chore: EN 번역 자동 업데이트 [skip-notion]"
3945
git pull --rebase origin main
4046
git push origin main
47+
echo "pushed=true" >> $GITHUB_OUTPUT
48+
49+
# GITHUB_TOKEN 으로 push 한 커밋은 deploy.yml(on: push)을 트리거하지 못한다
50+
# (GitHub의 워크플로 재귀 방지). workflow_dispatch 는 예외라 명시 호출로 배포를 잇는다.
51+
- name: Trigger deploy
52+
if: steps.commit.outputs.pushed == 'true'
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: gh workflow run deploy.yml --ref main

scripts/server-sync.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# Notion → docs/ 동기화 → git push
3-
# 서버 crontab에서 3시간마다 실행 (0 */3 * * *)
3+
# 서버 crontab에서 6시간마다 실행 (0 */6 * * *)
44

55
set -e
66

@@ -23,6 +23,19 @@ trap 'if [ -n "$ORIG_BRANCH" ] && [ "$ORIG_BRANCH" != "main" ]; then git checkou
2323
# 진행 중인 rebase 중단 (이전 실행 충돌로 잠긴 경우 해제)
2424
git rebase --abort 2>/dev/null || true
2525

26+
# 커밋 안 한 로컬 변경을 stash로 치운다 — checkout·pull 보다 먼저.
27+
# 이게 없으면 파일 하나가 pull --rebase 를 영구히 막아 동기화가 통째로 멈춘다
28+
# (2026-07-21 ~ 08-11, 42회 연속 실패한 실제 사례).
29+
# 추적 파일만 대상이며 stash에 보존되므로 작업은 유실되지 않는다: git stash list / git stash pop
30+
if ! git diff --quiet HEAD; then
31+
echo "[$(date)] WARN: 커밋되지 않은 로컬 변경 감지 — stash 처리 (git stash list 로 복구 가능)"
32+
git diff --name-only HEAD
33+
if ! git stash push -m "server-sync auto-stash $(date +'%Y-%m-%d %H:%M')" --quiet; then
34+
echo "[$(date)] ERROR: stash 실패, 스킵"
35+
exit 1
36+
fi
37+
fi
38+
2639
# 항상 main에서 실행 보장 (실패 시 즉시 종료)
2740
if ! git checkout main --quiet 2>/dev/null; then
2841
echo "[$(date)] ERROR: main 브랜치 checkout 실패, 스킵"

0 commit comments

Comments
 (0)