Hotfix/loseminho : terminated 상태 조회 제거 #166
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Delete Branch | |
| on: | |
| pull_request: | |
| types: [ closed ] | |
| jobs: | |
| delete-branch: | |
| if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # PR과 연관된 이슈들 닫기 | |
| - name: Close linked issues | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const pr = context.payload.pull_request; | |
| const text = `${pr.title}\n${pr.body || ''}`; | |
| // 🔍 (#123) 같은 패턴 찾기 | |
| const issueMatches = [...text.matchAll(/\(#(\d+)\)/g)].map(m => m[1]); | |
| if (issueMatches.length === 0) { | |
| console.log('ℹ️ No linked issues found in PR'); | |
| } else { | |
| for (const issueNumber of issueMatches) { | |
| console.log(`✅ Closing issue #${issueNumber}`); | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| state: "closed" | |
| }); | |
| } | |
| } | |
| // 🗑️ 병합된 브랜치 삭제 (main, dev 보호) | |
| const headBranch = pr.head.ref; | |
| const protectedBranches = ['main', 'dev']; | |
| if (!protectedBranches.includes(headBranch)) { | |
| console.log(`🗑️ Deleting branch: ${headBranch}`); | |
| await github.rest.git.deleteRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: `heads/${headBranch}` | |
| }); | |
| } else { | |
| console.log(`⚠️ Skipping deletion of protected branch: ${headBranch}`); | |
| } |