Skip to content

[FEAT] merge, create PR 로직 분리#100

Merged
ujinsim merged 1 commit intomainfrom
feat/#84
Nov 16, 2025
Merged

[FEAT] merge, create PR 로직 분리#100
ujinsim merged 1 commit intomainfrom
feat/#84

Conversation

@ujinsim
Copy link
Copy Markdown
Collaborator

@ujinsim ujinsim commented Nov 16, 2025

🔥 연관 이슈

🚀 작업 내용

PR 생성은 PR 이벤트 속 workflow가 아니라 push 이벤트에서만 허용된다고 해서
pr merge 및 브랜치 생성 로직과 pr생성로직을 분리하였습니다

🤔 고민했던 내용

💬 리뷰 중점사항

Summary by CodeRabbit

Release Notes

  • Chores
    • 버전 범프 및 npm 퍼블리싱 프로세스 자동화 개선
    • CI/CD 워크플로우 최적화로 패키지 릴리스 절차 간소화

@ujinsim ujinsim self-assigned this Nov 16, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 16, 2025

Walkthrough

GitHub Actions 워크플로우를 재구성하여 버전 범프와 npm 배포 프로세스를 분리합니다. 새로운 bump-pr.yaml 워크플로우는 PR 생성, 자동 병합 및 npm 발행을 담당하고, 기존 bump-version.yaml은 버전 업데이트와 내보내기 동기화만 수행합니다.

Changes

Cohort / File(s) 변경 사항
새로운 버전 범프 PR 워크플로우
\.github/workflows/bump-pr\.yaml
새로운 워크플로우 추가: bump/* 브랜치 푸시 트리거 시 main으로의 PR 생성, 자동 병합, Node.js 20 설정, npm 의존성 설치 및 NPM_TOKEN을 사용한 npm 발행 수행
기존 버전 범프 워크플로우 단순화
\.github/workflows/bump-version\.yaml
워크플로우 명칭 변경, pull-requests 권한 제거, 조건부 확인 단순화(GitHub Actions 봇 제외 조건 제거), 노드 레지스트리 URL 설정 제거, 단계 레이블 변경, PR 생성/자동 병합/npm 발행 단계 제거, 변경사항 미감지 시 NO_CHANGES 플래그 설정 추가

Sequence Diagram(s)

sequenceDiagram
    participant Push as bump/* Push
    participant PR as bump-pr.yaml
    participant Main as main Branch
    participant NPM as npm Registry

    Push->>PR: 워크플로우 트리거
    PR->>Main: PR 생성 및 자동 병합
    Main->>Main: main 브랜치 체크아웃
    Main->>Main: Node.js 20 설정
    Main->>Main: npm ci로 의존성 설치
    Main->>NPM: NPM_TOKEN으로 npm publish

    Note over PR,Main: bump-version.yaml은<br/>main 병합 시 버전<br/>범프만 수행
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • 워크플로우 파일 구조가 명확하고 기존 로직의 재배치
  • bump-pr.yaml의 단계별 실행 흐름 검증 필요
  • bump-version.yaml의 권한 감소 및 조건부 로직 단순화 확인

Possibly related PRs

Suggested labels

chore

Suggested reviewers

  • yougyung
  • keemsebin

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경 사항을 명확하게 설명합니다. 워크플로우 로직 분리(merge, create PR)가 핵심 변경 내용이며, 제목이 이를 직접적으로 반영합니다.
Description check ✅ Passed PR 설명이 필수 섹션을 포함하고 있습니다. 연관 이슈(#84), 작업 내용(로직 분리 사유), 그리고 구조화된 형식을 갖추고 있어 리뷰어가 변경 사항을 이해할 수 있습니다.
Linked Issues check ✅ Passed PR이 이슈 #84의 목표를 충족합니다. 워크플로우 분리를 통해 npm 자동 배포와 버전 업데이트 자동화 기능이 구현되었으며, 두 개의 체크리스트 항목이 완료되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경 사항이 이슈 #84의 범위 내에 있습니다. 두 개의 워크플로우 파일 수정은 npm 배포 및 버저닝 자동화를 위한 로직 분리라는 목표에 직접 관련됩니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#84

Tip

📝 Customizable high-level summaries are now available!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide custom instructions to shape the summary (bullet lists, tables, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example:

"Create a concise high-level summary as a bullet-point list. Then include a Markdown table showing lines added and removed by each contributing author."


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the feat label Nov 16, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d55cb2b and d902d49.

📒 Files selected for processing (2)
  • .github/workflows/bump-pr.yaml (1 hunks)
  • .github/workflows/bump-version.yaml (4 hunks)
🔇 Additional comments (1)
.github/workflows/bump-version.yaml (1)

154-173: NO_CHANGESBRANCH_NAME 환경변수가 이후 스텝에서 사용되지 않습니다.

라인 162의 NO_CHANGES=true와 라인 172의 BRANCH_NAME=$BRANCH가 설정되지만, 워크플로우의 다음 스텝에서 참조되지 않습니다. 현재 워크플로우 구조상 이후 스텝이 없어 변경사항이 없어도 exit 0으로 정상 종료되므로 문제는 없지만, 이 환경변수들의 설정 의도가 명확하지 않습니다.

확인 요청: 두 워크플로우 간 통신을 위해 이 변수들이 필요한지, 아니면 정리할 수 있는지 확인 바랍니다.

Comment on lines +1 to +60
name: Create & Merge Bump PR

on:
push:
branches:
- 'bump/*'

permissions:
contents: write
pull-requests: write

jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Create PR
id: cpr
uses: actions/github-script@v7
with:
script: |
const branch = context.ref.replace('refs/heads/', '');

const pr = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'chore: bump version & sync exports',
head: branch,
base: 'main'
});

core.setOutput('pr_number', pr.data.number);

- name: Auto-merge PR
uses: actions/github-script@v7
with:
script: |
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ steps.cpr.outputs.pr_number }}
});

- name: Checkout merged main
uses: actions/checkout@v4
with:
ref: main

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

두 워크플로우 간 타이밍 문제 및 race condition 가능성을 검토하세요.

bump-version.yamlbump/* 브랜치를 푸시하면, 이 워크플로우(bump-pr.yaml)가 자동 트리거됩니다. 하지만:

  1. 푸시 이후 워크플로우 트리거 사이의 지연
  2. bump-version.yaml이 동일한 조건(main 브랜치 머지)에서 반복 실행되면 여러 bump 브랜치 생성 가능
  3. 여러 bump 브랜치가 동시에 PR을 생성하면 순서 보장 안 됨

제안: bump-pr.yaml 실행 중 새 bump 브랜치 푸시에 대한 동시 실행 제어(concurrency) 설정 추가 검토

concurrency:
  group: bump-and-publish
  cancel-in-progress: false
🤖 Prompt for AI Agents
.github/workflows/bump-pr.yaml lines 1-60: this workflow can run concurrently
when multiple bump/* branches are pushed causing race conditions; add a
top-level concurrency stanza to serialize or control overlapping runs (place it
directly under the workflow name) — set a stable group name (for example a
constant group like bump-and-publish or scoped with the ref/branch using GitHub
context) and set cancel-in-progress to the desired behavior (use
cancel-in-progress: false as suggested to avoid canceling running jobs) so only
one bump-pr workflow run proceeds at a time and new runs are queued or blocked.

Comment on lines +16 to +31
- name: Create PR
id: cpr
uses: actions/github-script@v7
with:
script: |
const branch = context.ref.replace('refs/heads/', '');

const pr = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'chore: bump version & sync exports',
head: branch,
base: 'main'
});

core.setOutput('pr_number', pr.data.number);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

PR 생성 실패 시 다음 단계 진행 방지 필요합니다.

라인 31에서 pr_number를 출력한 후, 라인 33의 auto-merge 스텝이 무조건 실행됩니다. PR 생성이 실패해도 워크플로우는 계속 진행되어 존재하지 않는 PR 번호로 merge 요청을 시도하게 됩니다.

제안: if: success() 조건을 auto-merge 스텝에 추가하거나, 스크립트에 명시적 에러 처리를 추가하세요.

      - name: Auto-merge PR
        if: success()
        uses: actions/github-script@v7
        with:
          script: |
            await github.rest.pulls.merge({
              owner: context.repo.owner,
              repo: context.repo.repo,
              pull_number: ${{ steps.cpr.outputs.pr_number }}
            });
🤖 Prompt for AI Agents
.github/workflows/bump-pr.yaml lines 16-31: the workflow sets and outputs
pr_number even if the PR creation fails, allowing a subsequent auto-merge step
to run against a non-existent PR; fix by making PR creation fail-fast or gating
the auto-merge step: either catch errors from github.rest.pulls.create and
rethrow (or call core.setFailed) so the workflow stops and do not set the output
on failure, or keep the script as-is but add if: success() to the Auto-merge PR
step so it only runs when prior steps succeeded.

Comment on lines +33 to +41
- name: Auto-merge PR
uses: actions/github-script@v7
with:
script: |
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ steps.cpr.outputs.pr_number }}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

PR merge 실패 시 npm publish 진행 방지가 필요합니다.

라인 33-41의 auto-merge 스텝이 실패해도 (예: 충돌 발생) 라인 57의 npm publish는 여전히 실행됩니다. 이는 구 버전의 npm 패키지가 배포될 수 있다는 뜻입니다.

제안:

  1. Auto-merge 스텝 및 checkout 스텝에 if: success() 추가
  2. 또는 merge 성공 여부를 출력으로 반환하고 npm publish 전 확인
      - name: Checkout merged main
        if: success()
        uses: actions/checkout@v4
        with:
          ref: main

      - name: Publish to npm
        if: success()
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
🤖 Prompt for AI Agents
.github/workflows/bump-pr.yaml lines 33-41: the auto-merge step can fail (e.g.,
conflict) but subsequent steps still run causing npm publish of an unmerged/main
version; ensure downstream steps only run when merge succeeded by adding a
success gate or explicit merge result check. Update the workflow so the
auto-merge step and the following checkout step include a conditional like if:
success(), and gate the Publish to npm step with if: success() (or alternatively
have the merge step set an output indicating success and make the publish step
depend on that output) so npm publish only runs when the merge completed
successfully.

@ujinsim ujinsim merged commit f05faf4 into main Nov 16, 2025
6 checks passed
@ujinsim ujinsim deleted the feat/#84 branch November 16, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] main 브랜치 머지 시 npm 자동 배포 및 버저닝 설정

1 participant