-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (136 loc) · 5.43 KB
/
sync-to-frontend.example.yml
File metadata and controls
161 lines (136 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Sync API Hooks to Frontend
# 🔄 Bruno 리포의 .bru 파일이 변경되면 자동으로 프론트엔드 리포에 React Query 훅을 생성하고 PR을 만듭니다
#
# 사용 전 설정:
# 1. GitHub App 생성 및 설치 (docs/GITHUB-APPS-SETUP.md 참고)
# 2. Secrets 설정: APP_ID, APP_PRIVATE_KEY
# 3. 아래 YOUR_* 부분을 실제 값으로 변경
on:
push:
branches:
- main # 또는 master
paths:
- '**.bru' # .bru 파일이 변경될 때만 실행
workflow_dispatch: # 수동 실행 가능
jobs:
generate-and-sync:
runs-on: ubuntu-latest
steps:
# 1. GitHub App 토큰 생성
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
# ⚠️ 변경 필요: 본인의 GitHub 사용자명 또는 조직명
owner: YOUR_GITHUB_USERNAME
# ⚠️ 변경 필요: Bruno 리포와 프론트엔드 리포 이름 (쉼표로 구분)
repositories: "bruno-repo-name,frontend-repo-name"
# 2. Bruno 리포 체크아웃
- name: Checkout Bruno Repo
uses: actions/checkout@v4
with:
path: bruno-repo
# 3. 프론트엔드 리포 체크아웃
- name: Checkout Frontend Repo
uses: actions/checkout@v4
with:
# ⚠️ 변경 필요: 프론트엔드 리포 경로 (예: manNomi/my-frontend-app)
repository: YOUR_USERNAME/YOUR_FRONTEND_REPO
token: ${{ steps.generate-token.outputs.token }}
path: frontend-repo
# 4. Node.js 설정
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
# 5. bruno-api-typescript 설치
- name: Install bruno-api-typescript
run: |
cd frontend-repo
npm install -D github:manNomi/bruno-api-typescript
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
# 6. React Query 훅 생성
- name: Generate React Query Hooks
run: |
cd frontend-repo
npx bruno-api generate-hooks \
-i ../bruno-repo/bruno \
-o ./src/apis \
--axios-path "@/utils/axiosInstance"
# 7. 변경사항 확인
- name: Check for changes
id: git-check
run: |
cd frontend-repo
if [[ -n $(git status -s) ]]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "✅ Changes detected"
else
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "ℹ️ No changes detected"
fi
# 8. 브랜치 생성 및 커밋
- name: Commit and Push Changes
if: steps.git-check.outputs.has_changes == 'true'
run: |
cd frontend-repo
# Git 설정
git config user.name "bruno-api-sync-bot[bot]"
git config user.email "bruno-api-sync-bot[bot]@users.noreply.github.com"
# 브랜치 생성
BRANCH_NAME="auto/update-api-hooks-$(date +%Y%m%d-%H%M%S)"
git checkout -b $BRANCH_NAME
# 커밋
git add src/apis
git commit -m "chore: update API hooks from Bruno
🤖 Auto-generated by bruno-api-typescript
Source: ${{ github.repository }}@${{ github.sha }}
Triggered by: ${{ github.actor }}"
# 푸시
git push origin $BRANCH_NAME
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
id: commit
# 9. PR 생성
- name: Create Pull Request
if: steps.git-check.outputs.has_changes == 'true'
working-directory: frontend-repo
run: |
gh pr create \
--title "🔄 Update API Hooks from Bruno" \
--body "## 🤖 Auto-generated PR
React Query 훅이 Bruno API 변경사항을 반영하여 업데이트되었습니다.
### 📋 Source Information
- **Repository**: \`${{ github.repository }}\`
- **Commit**: [\`${GITHUB_SHA:0:7}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
- **Triggered by**: @${{ github.actor }}
### 📦 Generated Files
- \`src/apis/**/*.ts\` - React Query hooks
- \`src/apis/queryKeys.ts\` - Query key constants
### ✅ Review Checklist
- [ ] Breaking changes 확인
- [ ] 변경된 API 사용하는 컴포넌트 업데이트
- [ ] \`npm run type-check\` 실행
- [ ] 테스트 실행 (\`npm test\`)
---
*Generated by [bruno-api-typescript](https://github.com/manNomi/bruno-api-typescript)*
" \
--base main \
--head ${{ steps.commit.outputs.branch_name }} \
--label "auto-generated" \
--label "api-update"
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
# 10. 결과 요약
- name: Summary
run: |
echo "## 🎉 Workflow Completed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ steps.git-check.outputs.has_changes }}" == "true" ]]; then
echo "✅ PR created successfully!" >> $GITHUB_STEP_SUMMARY
echo "- Branch: \`${{ steps.commit.outputs.branch_name }}\`" >> $GITHUB_STEP_SUMMARY
else
echo "ℹ️ No changes detected. PR not created." >> $GITHUB_STEP_SUMMARY
fi