Skip to content

Conversation

@jjamming
Copy link
Contributor

@jjamming jjamming commented Nov 13, 2025

💡 To Reviewers

  • github의 관련이슈는 기본 브랜치(현재는 main)에만 PR이 병합될 때 닫힙니다. 이를 dev 브랜치에 병합시에도 삭제되게 하여 이슈 목록을 깔끔하게 유지합니다.
  • 소스 브랜치 또한 병합될 시 삭제하여 브랜치 목록을 깔끔하게 유지합니다.

🔥 작업 내용 (가능한 구체적으로 작성해 주세요)

  • PR이 dev 브랜치에 병합될 때 이슈 번호를 인식하여 자동으로 닫히게 하는 워크플로우 파일 생성

🤔 추후 작업 예정

  • github 세팅 오류가 나면 조치 예정

📸 작업 결과 (스크린샷)

  • .

🔗 관련 이슈

Summary by CodeRabbit

  • Chores
    • Added an automated "PR merge cleanup" workflow: when a pull request is merged into main or dev it closes linked issues referenced with common keywords (e.g., close, fixes, resolves), attempts to delete the source branch, reports per-issue success/failure counts and a summary, and tolerates branch deletion failures.

@jjamming jjamming self-assigned this Nov 13, 2025
@jjamming jjamming added the 🔨 chore 그 외 잡무 (예: 콘솔 제거) label Nov 13, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a GitHub Actions workflow that runs when a pull request is merged into dev or main; it closes linked issues found in the PR body using the GitHub CLI and then attempts to delete the PR source branch, handling failures gracefully.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
​.github/workflows/pr-merge-cleanup.yml
New workflow "PR Merge Cleanup" triggered on pull_request.closed for base branches dev or main; checks out repo, parses PR body for issue-closing keywords (close, closes, fix, fixes, resolve, resolves), closes matched issues via gh issue close with reason completed, reports counts, then attempts to delete the source branch via gh api while tolerating deletion failures.

Sequence Diagram

sequenceDiagram
    actor GitHub as GitHub Event
    participant Workflow as PR Merge Cleanup
    participant Repo as Repository
    participant CLI as gh CLI
    participant Issues as Issue Tracker

    GitHub->>Workflow: PR closed & merged to dev/main
    Workflow->>Repo: actions/checkout
    rect rgb(230,240,255)
      Note over Workflow: Parse PR body for issue references\n(keywords + `#number`)
      Workflow->>CLI: gh issue close `#NNN` --reason completed
      CLI->>Issues: Close issue
      Workflow->>Workflow: Tally successes/failures
    end
    rect rgb(235,255,230)
      Note over Workflow: Delete source branch
      Workflow->>CLI: gh api repos/{owner}/{repo}/git/refs/heads/{branch} -X DELETE
      alt deletion succeeds
        CLI->>Repo: Remove branch ref
      else deletion fails (not found/permission)
        Workflow->>Workflow: Log and continue
      end
    end
    Workflow-->>GitHub: Complete (summary)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Check regex used to detect issue-closing phrases and issue number capture.
  • Validate workflow permissions and whether GITHUB_TOKEN scope is sufficient.
  • Review branch-deletion API call and its error handling/log messages.

Poem

🐇 I sniff the PR, then hop and see,
I close the bugs that once bothered thee,
A tidy branch I gently sweep,
So code can rest, content to sleep. ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title is in Korean and describes adding a workflow for closing issues, which aligns with the main change of introducing a GitHub Actions workflow for automatic issue closure.
Linked Issues check ✅ Passed The workflow correctly implements automatic issue closing for both dev and main branches with branch deletion, matching the core requirement to close issues when PRs merge to dev, not just main.
Out of Scope Changes check ✅ Passed The changes are limited to the new workflow file and directly address the linked issue objectives without introducing unrelated modifications.
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 chore-6

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
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a GitHub Actions workflow to automatically close linked issues when pull requests are merged to the dev branch, not just the default main branch. This helps maintain a cleaner issue tracking process.

  • Added workflow that triggers on PR close events
  • Configured to detect issue-closing keywords (close, fix, resolve) in PR descriptions
  • Uses GitHub CLI to automatically close referenced issues when PRs merge to dev or main branches

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

shell: bash
run: |
echo "🔍 PR 내용에서 이슈 닫는 키워드를 찾는 중..."
printf '%s' "$PR_BODY" | tr -d '\r' | grep -Eoi '(close[sd]?|fix(e[sd])?|resolve[sd]?) #[0-9]+' | while read -r match; do
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

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

The regex pattern used here may not correctly match keywords with plural forms. The pattern close[sd]? will match "close", "closes", or "closed", but fix(e[sd])? will only match "fix", "fixes", "fixed" - it won't match "fixe" which is not a valid word anyway. However, the pattern should be fix(e[sd]?)? to properly match "fix", "fixed", "fixes". Similarly, resolve[sd]? will match "resolve", "resolves", "resolved" correctly.

Consider updating the regex to: (close[sd]?|fix(e[sd]?)?|resolve[sd]?) #[0-9]+

This ensures "fixed" and "fixes" are both properly matched.

Suggested change
printf '%s' "$PR_BODY" | tr -d '\r' | grep -Eoi '(close[sd]?|fix(e[sd])?|resolve[sd]?) #[0-9]+' | while read -r match; do
printf '%s' "$PR_BODY" | tr -d '\r' | grep -Eoi '(close[sd]?|fix(e[sd]?)?|resolve[sd]?) #[0-9]+' | while read -r match; do

Copilot uses AI. Check for mistakes.
Copy link

@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: 0

🧹 Nitpick comments (1)
.github/workflows/auto-close-issues.yml (1)

22-23: Consider removing the unnecessary Checkout step.

The workflow only uses the GitHub CLI to interact with the GitHub API and doesn't reference any local repository files. The actions/checkout@v4 step is not needed here and can be removed to streamline the workflow.

Apply this diff to remove the unnecessary step:

    steps:
-     - name: Checkout
-       uses: actions/checkout@v4
-
     - name: Close linked issues via gh CLI
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5005c15 and 934d6bf.

📒 Files selected for processing (1)
  • .github/workflows/auto-close-issues.yml (1 hunks)
🔇 Additional comments (2)
.github/workflows/auto-close-issues.yml (2)

32-32: Verify regex pattern matches intended GitHub closing keywords.

The regex pattern fix(e[sd])? may produce unintended matches. Specifically:

  • Intended matches: "fix", "fixes", "fixed"
  • Actual matches: "fix", "fixe", "fixes", "fixed"

The substring "fixe" alone is not a standard GitHub closing keyword. Consider whether this is intentional or if the pattern should be fix(es|ed)? instead.

If this was unintentional, apply this diff:

-          printf '%s' "$PR_BODY" | tr -d '\r' | grep -Eoi '(close[sd]?|fix(e[sd])?|resolve[sd]?) #[0-9]+' | while read -r match; do
+          printf '%s' "$PR_BODY" | tr -d '\r' | grep -Eoi '(close[sd]?|fix(es|ed)?|resolve[sd]?) #[0-9]+' | while read -r match; do

10-36: Workflow logic is sound.

The overall approach is correct: conditional execution on merged PRs targeting dev/main, appropriate permissions, proper GitHub CLI usage, and graceful handling of edge cases (empty body, multiple issues). The workflow will successfully close linked issues as intended.

@github-actions
Copy link

@github-actions
Copy link

Copy link

@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: 0

🧹 Nitpick comments (1)
.github/workflows/pr-merge-cleanup.yml (1)

17-20: Minor: Unused permission scope.

Line 19 requests pull-requests: write, but the workflow only closes issues (line 48) and deletes branches (line 67). The issues: write and contents: write permissions should suffice. Removing pull-requests: write follows the principle of least privilege.

    permissions:
      issues: write
-     pull-requests: write
      contents: write
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d125361 and ef6a79b.

📒 Files selected for processing (1)
  • .github/workflows/pr-merge-cleanup.yml (1 hunks)
🔇 Additional comments (2)
.github/workflows/pr-merge-cleanup.yml (2)

26-58: Robust issue-closing implementation.

The issue extraction and closing logic is solid. The regex pattern correctly captures all three keyword families, deduplication prevents retries, early exit saves cycles when no issues are found, and error handling with counters enables clear reporting. The validation of non-empty issue numbers (line 46) guards against malformed grep output.


60-67: Branch deletion is appropriately fault-tolerant.

The branch deletion gracefully handles failures (already deleted, missing permissions, etc.) and won't block the workflow. This aligns well with the PR objective of keeping the branch list clean while remaining resilient.

Copy link
Member

@psm1st psm1st left a comment

Choose a reason for hiding this comment

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

고생하셨어요~

@jjamming jjamming merged commit ad62f6f into main Nov 13, 2025
2 checks passed
@github-actions github-actions bot deleted the chore-6 branch November 13, 2025 04:17
@jjamming jjamming restored the chore-6 branch November 13, 2025 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 chore 그 외 잡무 (예: 콘솔 제거)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[chore] pr 병합시 관련 이슈 닫기 워크플로우 추가

3 participants