feat[project-setting] 프로젝트 생성 및 CI/CD 파이프라인 구축 #1
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: Create branch from issue | |
| on: | |
| issues: | |
| types: [opened, labeled] # 이슈 생성 또는 라벨 붙을 때 작동 | |
| jobs: | |
| create-branch: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Decide branch prefix | |
| id: prefix | |
| run: | | |
| PREFIX="feat" # 기본값 | |
| for label in ${{ join(github.event.issue.labels.*.name, ' ') }}; do | |
| if [[ "$label" =~ ^(feat|bug|refactor|chore)$ ]]; then | |
| PREFIX=$label | |
| break | |
| fi | |
| done | |
| echo "prefix=$PREFIX" >> $GITHUB_OUTPUT | |
| - name: Get custom branch name from issue body | |
| id: custom | |
| run: | | |
| CUSTOM=$(echo "${{ github.event.issue.body }}" | grep -oP '(?<=/branch-name ).*' || true) | |
| if [ -n "$CUSTOM" ]; then | |
| echo "custom_name=$CUSTOM" >> $GITHUB_OUTPUT | |
| else | |
| echo "custom_name=" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create branch | |
| run: | | |
| ISSUE_NUMBER=${{ github.event.issue.number }} | |
| ISSUE_TITLE=${{ github.event.issue.title }} | |
| SANITIZED_TITLE=$(echo "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9' '-') | |
| BRANCH_NAME="${{ steps.prefix.outputs.prefix }}/${ISSUE_NUMBER}-${SANITIZED_TITLE}" | |
| echo "Creating branch: $BRANCH_NAME" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git fetch origin main | |
| git checkout -b "$BRANCH_NAME" origin/main | |
| git push origin "$BRANCH_NAME" |