Skip to content

LC-2857 ADMIN 마그넷 내부화 신청폼 관리 #299

LC-2857 ADMIN 마그넷 내부화 신청폼 관리

LC-2857 ADMIN 마그넷 내부화 신청폼 관리 #299

Workflow file for this run

name: Auto add LC ticket block and normalize title
on:
pull_request:
types: [opened, synchronize, edited]
jobs:
add-lc-block:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Add LC block from branch name
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const body = pr.body || '';
const branch = pr.head.ref || '';
// 브랜치 이름에서 LC-숫자 패턴 추출 (예: LC-2543)
const match = branch.match(/LC-\d+/i);
if (!match) {
core.info(`브랜치명에 LC-숫자 패턴이 없습니다. branch: ${branch}`);
return;
}
const lcId = match[0].toUpperCase(); // LC-2543 형태로
// 이미 같은 링크 블록이 있으면 중복 추가 방지
if (
body.includes(`[${lcId}]`) ||
body.includes(`${lcId}]:https://letscareer-team.atlassian.net/browse/${lcId}`)
) {
core.info(`PR 본문에 이미 ${lcId} 관련 내용이 있습니다. 아무 것도 하지 않습니다.`);
return;
}
// 추가할 블록 생성
const lcBlock = `- [${lcId}]\n\n[${lcId}]:https://letscareer-team.atlassian.net/browse/${lcId}\n`;
// PR 본문 뒤에 붙이기
const newBody = body.trim() + '\n\n' + lcBlock;
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
body: newBody,
});
core.info(`PR 본문에 ${lcId} 블록을 추가했습니다.`);
normalize-title:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Set PR title from branch
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const branch = pr.head.ref || '';
// 예: LC-2761-USER-파일명-인코딩-수정, feature/LC-2761-USER-...
if (!branch) {
core.info('브랜치 이름을 찾지 못했습니다.');
return;
}
// 브랜치명에서 LC-숫자 패턴 추출
const lcMatch = branch.match(/LC-\d+/i);
if (!lcMatch) {
core.info(`LC 번호가 브랜치명에 없음: ${branch}`);
return;
}
const lcId = lcMatch[0].toUpperCase(); // LC-2761
// LC-2761 뒤를 잘라냄
const afterLc = branch.split(lcMatch[0])[1] || '';
// 예: "-USER-파일명-인코딩-수정" 또는 "/USER-..."
// 앞의 / 또는 - 제거 후, 나머지 - /를 공백으로 변환
const cleaned = afterLc
.replace(/^[\/-]+/, '') // 맨 앞 구분자 제거
.replace(/[-\/]+/g, ' ') // 나머지 구분자를 공백으로 변환
.trim();
// cleaned가 없으면 LC-XXXX만 제목으로 사용
const newTitle = cleaned ? `${lcId} ${cleaned}` : lcId;
if (pr.title === newTitle) {
core.info(`PR 제목이 이미 동일합니다: ${newTitle}`);
return;
}
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
title: newTitle,
});
core.info(`PR 제목을 "${newTitle}" 로 변경했습니다.`);