Skip to content

Commit 2a72546

Browse files
committed
crone: ci-cd
1 parent d98cd21 commit 2a72546

File tree

2 files changed

+81
-126
lines changed

2 files changed

+81
-126
lines changed

.github/workflows/dev-ci.yml

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Development CI
1+
name: 개발 환경 CI
22

33
on:
44
pull_request:
@@ -13,36 +13,54 @@ env:
1313

1414
jobs:
1515
build-and-test:
16-
name: Build and Test
16+
name: 빌드 및 테스트
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- name: Checkout code
20+
- name: 소스 코드 체크아웃
2121
uses: actions/checkout@v4
2222

23-
- name: Setup .NET
23+
- name: .NET 환경 설정
2424
uses: actions/setup-dotnet@v4
2525
with:
2626
dotnet-version: ${{ env.DOTNET_VERSION }}
2727

28-
- name: Cache NuGet packages
28+
- name: NuGet 패키지 캐싱
2929
uses: actions/cache@v4
3030
with:
3131
path: ~/.nuget/packages
3232
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
3333
restore-keys: |
3434
${{ runner.os }}-nuget-
3535
36-
- name: Restore dependencies
37-
run: dotnet restore ProjectVG.sln
36+
- name: 종속성 복원
37+
run: |
38+
echo "복원 중..."
39+
start_time=$(date +%s)
40+
dotnet restore ProjectVG.sln
41+
end_time=$(date +%s)
42+
duration=$((end_time - start_time))
43+
echo "복원 완료 (${duration}초)"
3844
39-
- name: Build solution
40-
run: dotnet build ProjectVG.sln --no-restore --configuration Release
45+
- name: 솔루션 빌드
46+
run: |
47+
echo "🔨 빌드 중..."
48+
start_time=$(date +%s)
49+
dotnet build ProjectVG.sln --no-restore --configuration Release
50+
end_time=$(date +%s)
51+
duration=$((end_time - start_time))
52+
echo "빌드 완료 (${duration}초)"
4153
42-
- name: Run tests
43-
run: dotnet test ProjectVG.Tests/ProjectVG.Tests.csproj --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage
54+
- name: 단위 테스트 실행
55+
run: |
56+
echo "테스트 중..."
57+
start_time=$(date +%s)
58+
dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage
59+
end_time=$(date +%s)
60+
duration=$((end_time - start_time))
61+
echo "테스트 완료 (${duration}초)"
4462
45-
- name: Code Coverage Report
63+
- name: 코드 커버리지 리포트 생성
4664
uses: irongut/CodeCoverageSummary@v1.3.0
4765
with:
4866
filename: coverage/**/coverage.cobertura.xml
@@ -55,23 +73,24 @@ jobs:
5573
output: both
5674
thresholds: '60 80'
5775

58-
- name: Add Coverage PR Comment
76+
- name: PR에 커버리지 결과 댓글 추가
5977
uses: marocchino/sticky-pull-request-comment@v2
6078
if: github.event_name == 'pull_request'
6179
with:
6280
recreate: true
6381
path: code-coverage-results.md
6482

65-
- name: Publish Test Results
83+
- name: 테스트 결과 발행
6684
uses: dorny/test-reporter@v1
6785
if: success() || failure()
6886
with:
69-
name: Test Results
87+
name: 테스트 결과
7088
path: coverage/*.trx
7189
reporter: dotnet-trx
7290

73-
- name: Build Status Check
91+
- name: 빌드 상태 확인
7492
if: failure()
7593
run: |
76-
echo "❌ Build or tests failed"
94+
echo "❌ 빌드 실패"
95+
echo "단계를 확인하세요."
7796
exit 1

.github/workflows/release-cicd.yml

Lines changed: 45 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Release CI/CD
22

33
on:
4-
pull_request:
4+
push:
55
branches: [release]
66
paths-ignore:
77
- '**.md'
@@ -10,15 +10,15 @@ on:
1010

1111
env:
1212
DOTNET_VERSION: '8.0.x'
13-
DOCKER_IMAGE_NAME: projectvgapi
13+
DOCKER_IMAGE_NAME: ghcr.io/projectvg/projectvgapi
14+
ACTOR: projectvg
1415

1516
jobs:
16-
build-and-test:
17-
name: Build and Test
17+
build:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- name: Checkout code
21+
- name: Checkout Repository
2222
uses: actions/checkout@v4
2323

2424
- name: Setup .NET
@@ -34,121 +34,57 @@ jobs:
3434
restore-keys: |
3535
${{ runner.os }}-nuget-
3636
37-
- name: Restore dependencies
38-
run: dotnet restore ProjectVG.sln
39-
40-
- name: Build solution
41-
run: dotnet build ProjectVG.sln --no-restore --configuration Release
42-
43-
- name: Run tests
44-
run: dotnet test ProjectVG.Tests/ProjectVG.Tests.csproj --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage
45-
46-
- name: Code Coverage Report
47-
uses: irongut/CodeCoverageSummary@v1.3.0
48-
with:
49-
filename: coverage/**/coverage.cobertura.xml
50-
badge: true
51-
fail_below_min: true
52-
format: markdown
53-
hide_branch_rate: false
54-
hide_complexity: true
55-
indicators: true
56-
output: both
57-
thresholds: '70 85'
37+
- name: 종속성 복원
38+
run: |
39+
echo "복원 중..."
40+
dotnet restore ProjectVG.sln
41+
echo "복원 완료"
5842
59-
- name: Publish Test Results
60-
uses: dorny/test-reporter@v1
61-
if: success() || failure()
62-
with:
63-
name: Release Test Results
64-
path: coverage/*.trx
65-
reporter: dotnet-trx
66-
67-
docker-build-push:
68-
name: Docker Build and Push
69-
runs-on: ubuntu-latest
70-
needs: build-and-test
71-
if: success()
72-
73-
steps:
74-
- name: Checkout code
75-
uses: actions/checkout@v4
76-
77-
- name: Set up Docker Buildx
78-
uses: docker/setup-buildx-action@v3
79-
80-
- name: Login to Docker Hub
43+
- name: 솔루션 빌드
44+
run: |
45+
echo "🔨 빌드 중..."
46+
dotnet build ProjectVG.sln --no-restore --configuration Release
47+
echo "빌드 완료"
48+
49+
- name: 단위 테스트 실행
50+
run: |
51+
echo "테스트 중..."
52+
dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --logger trx --results-directory coverage
53+
echo "테스트 완료"
54+
55+
- name: Login to GitHub Container Registry
8156
uses: docker/login-action@v3
8257
with:
83-
username: ${{ secrets.DOCKER_USERNAME }}
84-
password: ${{ secrets.DOCKER_PASSWORD }}
58+
registry: ghcr.io
59+
username: ${{ env.ACTOR }}
60+
password: ${{ secrets.GHCR_TOKEN }}
8561

86-
- name: Extract metadata
87-
id: meta
88-
uses: docker/metadata-action@v5
89-
with:
90-
images: ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}
91-
tags: |
92-
type=ref,event=pr,prefix=pr-
93-
type=raw,value=latest,enable={{is_default_branch}}
94-
type=sha,prefix={{branch}}-
95-
96-
- name: Build and push Docker image
97-
uses: docker/build-push-action@v5
98-
with:
99-
context: .
100-
file: ./ProjectVG.Api/Dockerfile
101-
push: true
102-
tags: ${{ steps.meta.outputs.tags }}
103-
labels: ${{ steps.meta.outputs.labels }}
104-
cache-from: type=gha
105-
cache-to: type=gha,mode=max
106-
platforms: linux/amd64
107-
target: production
62+
- name: Build and Push Docker Image
63+
run: |
64+
docker build -t ${{ env.DOCKER_IMAGE_NAME }}:latest -f ProjectVG.Api/Dockerfile .
65+
docker push ${{ env.DOCKER_IMAGE_NAME }}:latest
10866
109-
deploy-aws:
110-
name: Deploy to AWS
111-
runs-on: ubuntu-latest
112-
needs: [build-and-test, docker-build-push]
113-
if: success()
67+
deploy:
68+
needs: build
69+
runs-on: [self-hosted, deploy-runner]
11470

11571
steps:
116-
- name: Checkout code
117-
uses: actions/checkout@v4
72+
- name: Login to GitHub Container Registry
73+
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ env.ACTOR }} --password-stdin
11874

119-
- name: Configure AWS credentials
120-
uses: aws-actions/configure-aws-credentials@v4
121-
with:
122-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
123-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
124-
aws-region: ${{ secrets.AWS_REGION }}
125-
126-
- name: Extract Docker image tag
127-
id: image-tag
75+
- name: Add Private Files
12876
run: |
129-
echo "tag=${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE_NAME }}:pr-${{ github.event.number }}" >> $GITHUB_OUTPUT
77+
echo "${{ secrets.PROD_APPLICATION_ENV }}" | base64 --decode > .env
78+
echo "${{ secrets.PROD_DOCKER_COMPOSE }}" | base64 --decode > docker-compose.yml
13079
131-
# ECS 배포 예시 (필요시 수정)
132-
- name: Deploy to ECS
80+
- name: Run Deployment Script
81+
run: ./deploy.sh
82+
83+
- name: Cleanup Docker and Cache
13384
run: |
134-
# ECS 서비스 업데이트 (실제 클러스터명, 서비스명으로 수정 필요)
135-
aws ecs update-service \
136-
--cluster projectvg-cluster \
137-
--service projectvg-api-service \
138-
--task-definition projectvg-api-task \
139-
--force-new-deployment
140-
141-
echo "✅ Deployment initiated to AWS ECS"
142-
echo "🐳 Docker Image: ${{ steps.image-tag.outputs.tag }}"
143-
144-
# 또는 EC2/EKS 배포 예시
145-
# - name: Deploy to EC2/EKS
146-
# run: |
147-
# # 여기에 실제 배포 스크립트 작성
148-
# echo "Deploying to EC2/EKS..."
85+
docker system prune -af --volumes
14986
15087
- name: Deployment Status
15188
run: |
152-
echo "🚀 Release deployment completed successfully!"
153-
echo "📦 Image: ${{ steps.image-tag.outputs.tag }}"
154-
echo "🌍 Region: ${{ secrets.AWS_REGION }}"
89+
echo "🚀 배포 완료"
90+
echo "📦 이미지: ${{ env.DOCKER_IMAGE_NAME }}:latest"

0 commit comments

Comments
 (0)