Conversation
WalkthroughGitHub Actions 워크플로우를 재구성하여 버전 범프와 npm 배포 프로세스를 분리합니다. 새로운 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/>범프만 수행
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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.
Example:
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 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_CHANGES및BRANCH_NAME환경변수가 이후 스텝에서 사용되지 않습니다.라인 162의
NO_CHANGES=true와 라인 172의BRANCH_NAME=$BRANCH가 설정되지만, 워크플로우의 다음 스텝에서 참조되지 않습니다. 현재 워크플로우 구조상 이후 스텝이 없어 변경사항이 없어도exit 0으로 정상 종료되므로 문제는 없지만, 이 환경변수들의 설정 의도가 명확하지 않습니다.확인 요청: 두 워크플로우 간 통신을 위해 이 변수들이 필요한지, 아니면 정리할 수 있는지 확인 바랍니다.
| 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 }} |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
두 워크플로우 간 타이밍 문제 및 race condition 가능성을 검토하세요.
bump-version.yaml이 bump/* 브랜치를 푸시하면, 이 워크플로우(bump-pr.yaml)가 자동 트리거됩니다. 하지만:
- 푸시 이후 워크플로우 트리거 사이의 지연
bump-version.yaml이 동일한 조건(main 브랜치 머지)에서 반복 실행되면 여러 bump 브랜치 생성 가능- 여러 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.
| - 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); |
There was a problem hiding this comment.
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.
| - 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 }} | ||
| }); |
There was a problem hiding this comment.
PR merge 실패 시 npm publish 진행 방지가 필요합니다.
라인 33-41의 auto-merge 스텝이 실패해도 (예: 충돌 발생) 라인 57의 npm publish는 여전히 실행됩니다. 이는 구 버전의 npm 패키지가 배포될 수 있다는 뜻입니다.
제안:
- Auto-merge 스텝 및 checkout 스텝에
if: success()추가 - 또는 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.
🔥 연관 이슈
🚀 작업 내용
PR 생성은 PR 이벤트 속 workflow가 아니라 push 이벤트에서만 허용된다고 해서
pr merge 및 브랜치 생성 로직과 pr생성로직을 분리하였습니다
🤔 고민했던 내용
💬 리뷰 중점사항
Summary by CodeRabbit
Release Notes