git flow migration step 1 recommendation

written by Chat GPT 5

[스텝 1] 최소 셋업(수동 승급 & 자동 배포 최소한)

1) stage 브랜치 생성(메인에서)

2) 라벨/PR 템플릿/체크리스트 준비

3) dev 기능 분류(출시 가능 vs 대기)

4) stage 승급 PR 생성(수동)

5) 스테이징 배포(임시)

6) stage → main 머지 & 배포(프로덕션)

7) main → dev 백머지(자동, PR 없이)

2025-09-25 promo-to-stage.yml

# .github/workflows/promo-to-stage.yml
name: Promote labeled merges to stage
on:
  pull_request:
    types: [closed, labeled]
jobs:
  promote:
    if: >
      github.event.pull_request.merged == true &&
      contains(github.event.pull_request.labels.*.name, 'ready-for-stage') &&
      github.event.pull_request.base.ref == 'dev'
    runs-on: ubuntu-latest
    permissions: { contents: write, pull-requests: write }
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - run: |
          git fetch origin dev stage
          DEV_MERGE_SHA="${{ github.event.pull_request.merge_commit_sha }}"
          BR="promote/${{ github.event.pull_request.head.ref }}"
          git switch -c "$BR" origin/stage
          git cherry-pick "$DEV_MERGE_SHA"
          git push -u origin "$BR"
      - name: Open PR to stage
        uses: actions/github-script@v7
        with:
          script: |
            const pr = await github.rest.pulls.create({
              owner: context.repo.owner,
              repo: context.repo.repo,
              title: `Promote: ${context.payload.pull_request.title}`,
              head: `promote/${context.payload.pull_request.head.ref}`,
              base: 'stage',
              body: `Auto-promotion of ${context.payload.pull_request.html_url}`
            });

목적: Dev 환경에서 검증된 기능을 Stage 환경으로 자동 승격

동작 조건:

동작 방식:

  1. Dev에 머지된 커밋(merge_commit_sha)을 가져옴
  2. Stage 브랜치 기준으로 새 브랜치 생성 (promote/기존PR브랜치명)
  3. Cherry-pick으로 해당 커밋만 Stage로 가져옴
  4. Stage를 향한 새 PR 자동 생성

장점: