11name : Release CI/CD
22
33on :
4- pull_request :
4+ push :
55 branches : [release]
66 paths-ignore :
77 - ' **.md'
1010
1111env :
1212 DOTNET_VERSION : ' 8.0.x'
13- DOCKER_IMAGE_NAME : projectvgapi
13+ DOCKER_IMAGE_NAME : ghcr.io/projectvg/projectvgapi
14+ ACTOR : projectvg
1415
1516jobs :
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