refactor: 폴더명 및 파일명 패턴 통일 (대괄호 안에 영문키) #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |