Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# =============================================================================
# CODEOWNERS - 코드 소유자 설정
# =============================================================================
# 이 파일은 주석처리된 상태로 생성되었습니다.
# v1 완료 후 필요한 줄의 주석을 해제하여 사용하세요.
#
# 문법:
# <파일/폴더 패턴> @사용자1 @사용자2 ...
#
# 참고:
# - 파일 패턴은 .gitignore와 동일한 형식을 사용합니다.
# - 마지막에 매칭된 규칙이 적용됩니다 (순서 중요).
# - CODEOWNERS에 지정된 사용자는 자동으로 리뷰어로 요청됩니다.
# =============================================================================

# -----------------------------------------------------------------------------
# 전체 코드 기본 리뷰어
# -----------------------------------------------------------------------------
# * @team-lead @tech-lead

# -----------------------------------------------------------------------------
# GitHub Actions 및 CI/CD 설정
# -----------------------------------------------------------------------------
# .github/ @devops-team
# Dockerfile @devops-team
# docker-compose*.yml @devops-team

# -----------------------------------------------------------------------------
# 빌드 설정
# -----------------------------------------------------------------------------
# build.gradle* @backend-lead
# settings.gradle* @backend-lead
# gradle/ @backend-lead

# -----------------------------------------------------------------------------
# 애플리케이션 설정
# -----------------------------------------------------------------------------
# src/main/resources/application*.yml @backend-lead
# src/main/resources/application*.properties @backend-lead

# -----------------------------------------------------------------------------
# 도메인별 담당자 (예시)
# -----------------------------------------------------------------------------
# src/main/java/**/domain/user/ @user-domain-owner
# src/main/java/**/domain/order/ @order-domain-owner
# src/main/java/**/domain/payment/ @payment-domain-owner

# -----------------------------------------------------------------------------
# 인프라/공통 모듈
# -----------------------------------------------------------------------------
# src/main/java/**/common/ @backend-lead
# src/main/java/**/config/ @backend-lead
# src/main/java/**/security/ @security-lead
19 changes: 15 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## 🍀 이슈 번호
<!-- 이슈 번호를 작성해주세요 ex) #11 -->
## 🎫 지라 티켓

<!-- 지라 티켓을 작성해주세요 ex) UPLUS-3 -->

- #이슈번호

---

Expand All @@ -12,4 +12,15 @@

---

## ⌨ 기타
## 📋 체크리스트

<!-- PR 제출 전 확인해주세요. 해당 항목에 [x]로 체크해주세요. -->

- [ ] 코드가 정상적으로 빌드됩니다.
- [ ] 관련 테스트 코드를 작성했습니다.
- [ ] 기존 테스트가 모두 통과합니다.
- [ ] 코드 스타일(Spotless, Checkstyle)을 준수합니다.

---

## ⌨ 기타
135 changes: 129 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# ============================================================================
# Backend Deploy Workflow
# ============================================================================
# 이 파일을 backend 레포지토리의 .github/workflows/deploy.yml 로 저장하세요.
# 역할:
# - Integrate workflow 성공 후 자동 실행
# - integrate에서 생성된 JAR artifact 사용 (빌드 재수행 없음)
# - Docker 이미지 빌드 및 ECR 푸시
# - ECS 서비스 배포
#
# Job 구조:
# prepare ──> build-image ──> deploy
#
# 트리거:
# - Integrate Backend workflow가 main 브랜치에서 성공적으로 완료된 후
# - 수동 실행 (workflow_dispatch) - 최근 성공한 integrate run의 artifact 사용
#
# GitHub Secrets (Settings > Secrets and variables > Actions > Secrets):
# - AWS_ACCESS_KEY_ID: AWS IAM Access Key
Expand All @@ -16,7 +27,10 @@
name: Deploy Backend to ECS

on:
push:
workflow_run:
workflows: ["Integrate Backend"]
types:
- completed
branches:
- main
workflow_dispatch:
Expand All @@ -25,14 +39,104 @@ env:
AWS_REGION: ap-northeast-2

jobs:
deploy:
name: Build and Deploy
# ==========================================================================
# Prepare Job - Artifact 준비
# ==========================================================================
prepare:
name: Prepare
runs-on: ubuntu-latest
# workflow_run 트리거일 경우 integrate 성공 및 push 이벤트일 때만 실행
if: >
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push')

outputs:
run_id: ${{ steps.get-run-info.outputs.run_id }}
head_sha: ${{ steps.get-run-info.outputs.head_sha }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get workflow run info
id: get-run-info
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "Manual trigger detected. Finding latest successful integrate run..."

# 최근 성공한 Integrate Backend workflow run 조회
RUN_INFO=$(gh run list \
--workflow "Integrate Backend" \
--branch main \
--status success \
--event push \
--limit 1 \
--json databaseId,headSha)

RUN_ID=$(echo "$RUN_INFO" | jq -r '.[0].databaseId')
HEAD_SHA=$(echo "$RUN_INFO" | jq -r '.[0].headSha')

if [ "$RUN_ID" == "null" ] || [ -z "$RUN_ID" ]; then
echo "::error::No successful integrate workflow run found"
exit 1
fi

echo "Found run ID: $RUN_ID, commit: $HEAD_SHA"
else
echo "workflow_run trigger detected"
RUN_ID="${{ github.event.workflow_run.id }}"
HEAD_SHA="${{ github.event.workflow_run.head_sha }}"
fi

echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
echo "head_sha=$HEAD_SHA" >> $GITHUB_OUTPUT

- name: Download artifact from Integrate workflow
uses: actions/download-artifact@v4
with:
name: spring-boot-app
path: build/libs
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.get-run-info.outputs.run_id }}

- name: Verify and upload artifact
run: |
echo "Downloaded artifacts:"
ls -la build/libs/
JAR_FILE=$(ls build/libs/*.jar | head -1)
echo "JAR file: $JAR_FILE"

- name: Upload artifact for next jobs
uses: actions/upload-artifact@v4
with:
name: deploy-artifact
path: build/libs/*.jar
retention-days: 1

# ==========================================================================
# Build Image Job - Docker 빌드 및 ECR 푸시
# ==========================================================================
build-image:
name: Build Image
runs-on: ubuntu-latest
needs: [prepare]

outputs:
image_tag: ${{ needs.prepare.outputs.head_sha }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: deploy-artifact
path: build/libs

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -51,13 +155,30 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.deploy
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY }}:${{ github.sha }}
${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY }}:${{ needs.prepare.outputs.head_sha }}
${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max

# ==========================================================================
# Deploy Job - ECS 배포
# ==========================================================================
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [prepare, build-image]

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Deploy to ECS
run: |
aws ecs update-service \
Expand All @@ -76,7 +197,9 @@ jobs:
- name: Deployment Summary
run: |
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Image Tag**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Image Tag**: ${{ needs.prepare.outputs.head_sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Source Run ID**: ${{ needs.prepare.outputs.run_id }}" >> $GITHUB_STEP_SUMMARY
echo "- **ECS Cluster**: ${{ vars.ECS_CLUSTER }}" >> $GITHUB_STEP_SUMMARY
echo "- **ECS Service**: ${{ vars.ECS_SERVICE }}" >> $GITHUB_STEP_SUMMARY
echo "- **Region**: ${{ env.AWS_REGION }}" >> $GITHUB_STEP_SUMMARY
echo "- **Triggered by**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
Loading
Loading