Skip to content

Commit e40f02c

Browse files
authored
#86 [chore] GitHub Actions 배포 워크플로우 작성
# [chore] GitHub Actions 배포 워크플로우 작성 ## 📝 변경 내용 <!-- 이 PR에서 무엇을 변경했는지 간단히 설명해주세요 --> 배포 관련 스크립트 작성 ## 🔗 관련 이슈 <!-- 관련된 이슈가 있다면 링크해주세요 --> - Closes #85 ## 🎯 변경 사항 - [ ] 새로운 기능 추가 - [ ] 버그 수정 - [ ] UI/UX 개선 - [x] 리팩토링 - [ ] 문서 업데이트 ## 📱 테스트 - [x] 브라우저에서 정상 동작 확인 - [x] 기존 기능에 영향 없음 확인 ## 📋 체크리스트 - [x] 코드가 정상적으로 동작합니다 - [x] 새로운 에러나 경고가 없습니다 - [x] 필요시 문서를 업데이트했습니다 - [x] 코드 포맷팅을 실행했습니다 (`npm run format`) - [x] ESLint 검사를 통과했습니다 (`npm run lint:fix`) ## 💻 코드 품질 확인 PR 제출 전에 다음 명령어를 실행하여 코드 품질을 확인해주세요: ```bash # ESLint 자동 수정 npm run lint:fix # Prettier 포맷팅 npm run format ```
1 parent 60261ca commit e40f02c

5 files changed

Lines changed: 182 additions & 1 deletion

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Sync main branch to personal fork
2+
3+
on:
4+
# 원본 레포(main)에 커밋/머지될 때마다 자동 실행
5+
push:
6+
branches:
7+
- main
8+
9+
# 필요할 때 수동으로도 실행 가능
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
sync-to-fork:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout organization repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Configure Git user
26+
run: |
27+
git config user.name "github-actions[bot]"
28+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
29+
30+
- name: Push main to personal fork
31+
env:
32+
# 👉 여기 시크릿은 조직 레포의 Settings > Secrets and variables > Actions 에서
33+
# 개인 계정 PAT( repo 권한 )으로 만들어야 합니다. 예: PERSONAL_FORK_TOKEN
34+
PERSONAL_FORK_TOKEN: ${{ secrets.PERSONAL_FORK_TOKEN }}
35+
run: |
36+
if [ -z "$PERSONAL_FORK_TOKEN" ]; then
37+
echo "❌ PERSONAL_FORK_TOKEN 시크릿이 설정되어 있지 않습니다."
38+
exit 1
39+
fi
40+
41+
FORK_REPO_OWNER="dohy-eon"
42+
FORK_REPO_NAME="Valuedi_Web"
43+
44+
git remote add fork "https://x-access-token:${PERSONAL_FORK_TOKEN}@github.com/${FORK_REPO_OWNER}/${FORK_REPO_NAME}.git"
45+
46+
# 최신 main 기준으로 포크의 main을 덮어쓰기 (히스토리 유지하면서 fast-forward 또는 force-with-lease 가능)
47+
git push fork main:main
48+
49+

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"test": "vitest run",
1717
"test:watch": "vitest",
1818
"test:ui": "vitest --ui",
19-
"postinstall": "playwright install chromium"
19+
"postinstall": "playwright install chromium",
20+
"setup:fork": "./scripts/setup-fork.sh",
21+
"sync:upstream": "./scripts/sync-from-upstream.sh"
2022
},
2123
"dependencies": {
2224
"@tanstack/react-query": "^5.90.12",

scripts/setup-fork.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# Organization 저장소를 개인 포크로 설정하는 스크립트
4+
5+
set -e
6+
7+
echo "🔧 개인 포크 설정을 시작합니다..."
8+
9+
# GitHub CLI 인증 확인
10+
if ! gh auth status &>/dev/null; then
11+
echo "❌ GitHub CLI에 로그인되어 있지 않습니다."
12+
echo "다음 명령어로 로그인하세요:"
13+
echo " gh auth login"
14+
exit 1
15+
fi
16+
17+
# 현재 사용자 정보 가져오기
18+
GITHUB_USER=$(gh api user -q .login)
19+
echo "👤 GitHub 사용자: $GITHUB_USER"
20+
21+
# Organization 저장소 정보
22+
ORG_REPO="Valuedi/Valuedi_Web"
23+
FORK_REPO="$GITHUB_USER/Valuedi_Web"
24+
25+
echo "📦 Organization 저장소: $ORG_REPO"
26+
echo "🍴 포크할 저장소: $FORK_REPO"
27+
28+
# 포크가 이미 존재하는지 확인
29+
if gh repo view "$FORK_REPO" &>/dev/null; then
30+
echo "✅ 포크가 이미 존재합니다: $FORK_REPO"
31+
else
32+
echo "🍴 포크 생성 중..."
33+
gh repo fork "$ORG_REPO" --clone=false
34+
echo "✅ 포크 생성 완료!"
35+
fi
36+
37+
# 현재 origin 확인
38+
CURRENT_ORIGIN=$(git remote get-url origin 2>/dev/null || echo "")
39+
if [[ "$CURRENT_ORIGIN" == *"Valuedi/Valuedi_Web"* ]]; then
40+
echo "🔄 origin을 개인 포크로 변경 중..."
41+
git remote set-url origin "https://github.com/$FORK_REPO.git"
42+
echo "✅ origin이 개인 포크로 변경되었습니다"
43+
fi
44+
45+
# upstream이 없으면 추가
46+
if ! git remote | grep -q "^upstream$"; then
47+
echo "➕ upstream remote 추가 중..."
48+
git remote add upstream "https://github.com/$ORG_REPO.git"
49+
echo "✅ upstream이 추가되었습니다"
50+
else
51+
echo "✅ upstream이 이미 설정되어 있습니다"
52+
fi
53+
54+
# 원격 저장소 확인
55+
echo ""
56+
echo "📋 현재 원격 저장소 설정:"
57+
git remote -v
58+
59+
echo ""
60+
echo "✅ 설정 완료!"
61+
echo ""
62+
echo "이제 다음 명령어로 동기화할 수 있습니다:"
63+
echo " ./scripts/sync-from-upstream.sh"
64+
echo ""
65+
echo "또는 package.json의 스크립트를 사용하세요:"
66+
echo " npm run sync:upstream"

scripts/sync-from-upstream.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# Organization 저장소의 최신 변경사항을 개인 포크로 동기화하는 스크립트
4+
5+
set -e
6+
7+
echo "🔄 Organization 저장소에서 최신 변경사항 가져오는 중..."
8+
9+
# upstream이 설정되어 있는지 확인
10+
if ! git remote | grep -q "^upstream$"; then
11+
echo "❌ upstream remote가 설정되어 있지 않습니다."
12+
echo "다음 명령어로 설정하세요:"
13+
echo " git remote add upstream https://github.com/Valuedi/Valuedi_Web.git"
14+
exit 1
15+
fi
16+
17+
# 현재 브랜치 저장
18+
CURRENT_BRANCH=$(git branch --show-current)
19+
echo "📍 현재 브랜치: $CURRENT_BRANCH"
20+
21+
# upstream에서 최신 변경사항 가져오기
22+
echo "📥 upstream에서 fetch 중..."
23+
git fetch upstream
24+
25+
# main 브랜치로 전환
26+
echo "🔄 main 브랜치로 전환 중..."
27+
git checkout main
28+
29+
# upstream/main을 main에 병합
30+
echo "🔀 upstream/main을 main에 병합 중..."
31+
git merge upstream/main --no-edit
32+
33+
# 개인 포크에 푸시
34+
echo "📤 개인 포크(origin)에 푸시 중..."
35+
git push origin main
36+
37+
# 원래 브랜치로 돌아가기
38+
if [ "$CURRENT_BRANCH" != "main" ]; then
39+
echo "🔄 원래 브랜치($CURRENT_BRANCH)로 돌아가는 중..."
40+
git checkout "$CURRENT_BRANCH"
41+
fi
42+
43+
echo "✅ 동기화 완료!"

vercel.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"buildCommand": "npm run build",
3+
"outputDirectory": "dist",
4+
"rewrites": [
5+
{
6+
"source": "/(.*)",
7+
"destination": "/index.html"
8+
}
9+
],
10+
"headers": [
11+
{
12+
"source": "/assets/(.*)",
13+
"headers": [
14+
{
15+
"key": "Cache-Control",
16+
"value": "public, max-age=31536000, immutable"
17+
}
18+
]
19+
}
20+
]
21+
}

0 commit comments

Comments
 (0)