From 934d6bf9ffc2b2e1e44deb285cd2b9153516de77 Mon Sep 17 00:00:00 2001 From: jjamming Date: Thu, 13 Nov 2025 12:32:26 +0900 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=EC=9D=B4=EC=8A=88=20=EB=8B=AB?= =?UTF-8?q?=EA=B8=B0=20=EC=9B=8C=ED=81=AC=ED=94=8C=EB=A1=9C=EC=9A=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-close-issues.yml | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/auto-close-issues.yml diff --git a/.github/workflows/auto-close-issues.yml b/.github/workflows/auto-close-issues.yml new file mode 100644 index 0000000..8f5a2c7 --- /dev/null +++ b/.github/workflows/auto-close-issues.yml @@ -0,0 +1,37 @@ +name: Auto-close linked issues on PR merge + +on: + pull_request: + types: + - closed + +jobs: + close-linked-issues: + if: > + github.event.pull_request.merged == true && + ( + github.event.pull_request.base.ref == 'dev' || + github.event.pull_request.base.ref == 'main' + ) + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Close linked issues via gh CLI + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_BODY: ${{ github.event.pull_request.body }} + 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 + issue_number=$(echo "$match" | grep -oE '#[0-9]+' | tr -d '#') + echo "โžก๏ธ ๋‹ซ๋Š” ์ค‘: #$issue_number" + gh issue close "$issue_number" --reason completed --repo "$GITHUB_REPOSITORY" + done + From d1253619bdac58befe4d91cd91cf5b1a5ae4ad25 Mon Sep 17 00:00:00 2001 From: jjamming Date: Thu, 13 Nov 2025 12:39:13 +0900 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=ED=8C=8C=EC=9D=BC=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...uto-close-issues.yml => pr-merge-cleanup.yml} | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) rename .github/workflows/{auto-close-issues.yml => pr-merge-cleanup.yml} (65%) diff --git a/.github/workflows/auto-close-issues.yml b/.github/workflows/pr-merge-cleanup.yml similarity index 65% rename from .github/workflows/auto-close-issues.yml rename to .github/workflows/pr-merge-cleanup.yml index 8f5a2c7..c7cea89 100644 --- a/.github/workflows/auto-close-issues.yml +++ b/.github/workflows/pr-merge-cleanup.yml @@ -1,4 +1,4 @@ -name: Auto-close linked issues on PR merge +name: PR Merge Cleanup on: pull_request: @@ -6,7 +6,7 @@ on: - closed jobs: - close-linked-issues: + cleanup-after-merge: if: > github.event.pull_request.merged == true && ( @@ -16,7 +16,8 @@ jobs: runs-on: ubuntu-latest permissions: issues: write - pull-requests: read + pull-requests: write + contents: write steps: - name: Checkout @@ -35,3 +36,12 @@ jobs: gh issue close "$issue_number" --reason completed --repo "$GITHUB_REPOSITORY" done + - name: Delete source branch + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH_NAME: ${{ github.event.pull_request.head.ref }} + shell: bash + run: | + echo "๐Ÿ—‘๏ธ ์†Œ์Šค ๋ธŒ๋žœ์น˜ ์‚ญ์ œ ์ค‘: $BRANCH_NAME" + gh api repos/${{ github.repository }}/git/refs/heads/$BRANCH_NAME -X DELETE || echo "โš ๏ธ ๋ธŒ๋žœ์น˜ ์‚ญ์ œ ์‹คํŒจ ๋˜๋Š” ์ด๋ฏธ ์‚ญ์ œ๋จ: $BRANCH_NAME" + From ef6a79bde948fec676991e42ebb15821af4120fa Mon Sep 17 00:00:00 2001 From: jjamming Date: Thu, 13 Nov 2025 12:51:42 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=EC=98=88=EC=99=B8=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=97=90=EB=9F=AC=20=EC=B2=98=EB=A6=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr-merge-cleanup.yml | 32 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-merge-cleanup.yml b/.github/workflows/pr-merge-cleanup.yml index c7cea89..9fb7e44 100644 --- a/.github/workflows/pr-merge-cleanup.yml +++ b/.github/workflows/pr-merge-cleanup.yml @@ -30,11 +30,32 @@ jobs: 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 - issue_number=$(echo "$match" | grep -oE '#[0-9]+' | tr -d '#') - echo "โžก๏ธ ๋‹ซ๋Š” ์ค‘: #$issue_number" - gh issue close "$issue_number" --reason completed --repo "$GITHUB_REPOSITORY" - done + issue_count=0 + failed_count=0 + + # ์ด์Šˆ ๋ฒˆํ˜ธ ์ถ”์ถœ ๋ฐ ์ค‘๋ณต ์ œ๊ฑฐ + issue_numbers=$(printf '%s' "$PR_BODY" | tr -d '\r' | grep -Eoi '(close[sd]?|fix(e[sd])?|resolve[sd]?) #[0-9]+' | grep -oE '#[0-9]+' | tr -d '#' | sort -u) + + if [ -z "$issue_numbers" ]; then + echo "โ„น๏ธ PR ๋ณธ๋ฌธ์—์„œ ๋‹ซ์„ ์ด์Šˆ๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค." + exit 0 + fi + + # ๊ฐ ์ด์Šˆ ์ฒ˜๋ฆฌ + while IFS= read -r issue_number; do + if [ -n "$issue_number" ]; then + echo "โžก๏ธ ๋‹ซ๋Š” ์ค‘: #$issue_number" + if gh issue close "$issue_number" --reason completed --repo "$GITHUB_REPOSITORY"; then + echo "โœ… ์ด์Šˆ #$issue_number ๋‹ซ๊ธฐ ์™„๋ฃŒ" + issue_count=$((issue_count + 1)) + else + echo "โš ๏ธ ์ด์Šˆ #$issue_number ๋‹ซ๊ธฐ ์‹คํŒจ (์ด์Šˆ๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ ๊ถŒํ•œ์ด ์—†์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค)" + failed_count=$((failed_count + 1)) + fi + fi + done <<< "$issue_numbers" + + echo "๐Ÿ“Š ์ฒ˜๋ฆฌ ๊ฒฐ๊ณผ: ์„ฑ๊ณต $issue_count๊ฐœ, ์‹คํŒจ $failed_count๊ฐœ" - name: Delete source branch env: @@ -44,4 +65,3 @@ jobs: run: | echo "๐Ÿ—‘๏ธ ์†Œ์Šค ๋ธŒ๋žœ์น˜ ์‚ญ์ œ ์ค‘: $BRANCH_NAME" gh api repos/${{ github.repository }}/git/refs/heads/$BRANCH_NAME -X DELETE || echo "โš ๏ธ ๋ธŒ๋žœ์น˜ ์‚ญ์ œ ์‹คํŒจ ๋˜๋Š” ์ด๋ฏธ ์‚ญ์ œ๋จ: $BRANCH_NAME" -