Skip to content

Commit 65716b3

Browse files
authored
Merge pull request #391 from qwertyuiop4m/part3-김창우-spirnt8
[김창우] sprint8
2 parents 4552439 + 134fc8c commit 65716b3

38 files changed

+1171
-104205
lines changed
Binary file not shown.

.dockerignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/build
2+
/.gradle
3+
4+
.idea
5+
*.iml
6+
7+
.git
8+
.gitignore
9+
10+
.DS_Store
11+
*.log
12+
*.db
13+
.env
14+
15+
!gradlew
16+
!gradlew.bat

.env.test

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
AWS_S3_ACCESS_KEY=test
2+
AWS_S3_SECRET_KEY=test
3+
AWS_S3_REGION=ap-northeast-2
4+
AWS_S3_BUCKET=test-bucket
5+
AWS_S3_PRESIGNED_URL_EXPIRATION=600

.github/workflows/deploy.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CD - Deploy to ECS
2+
3+
on:
4+
push:
5+
branches:
6+
- release
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
13+
env:
14+
IMAGE_TAG: ${{ github.sha }}
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Configure AWS credentials (for ECR)
21+
uses: aws-actions/configure-aws-credentials@v4
22+
with:
23+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
24+
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
25+
aws-region: us-east-1
26+
27+
- name: Login to Public ECR
28+
run: |
29+
aws ecr-public get-login-password --region us-east-1 \
30+
| docker login --username AWS --password-stdin public.ecr.aws
31+
32+
- name: Build and Push Docker Image
33+
run: |
34+
docker build -t ${{ vars.ECR_REPOSITORY_URI }}:latest \
35+
-t ${{ vars.ECR_REPOSITORY_URI }}:${{ env.IMAGE_TAG }} .
36+
docker push ${{ vars.ECR_REPOSITORY_URI }}:latest
37+
docker push ${{ vars.ECR_REPOSITORY_URI }}:${{ env.IMAGE_TAG }}
38+
39+
- name: Configure AWS credentials (for ECS)
40+
uses: aws-actions/configure-aws-credentials@v2
41+
with:
42+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
43+
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
44+
aws-region: ${{ vars.AWS_REGION }}
45+
46+
- name: Render ECS task definition
47+
id: render-task
48+
uses: aws-actions/amazon-ecs-render-task-definition@v1
49+
with:
50+
task-definition: ecs/task-definition.json
51+
container-name: discodeit-app
52+
image: ${{ vars.ECR_REPOSITORY_URI }}:${{ env.IMAGE_TAG }}
53+
54+
- name: Register new ECS task definition
55+
id: register-task
56+
run: |
57+
TASK_DEF_ARN=$(aws ecs register-task-definition \
58+
--cli-input-json file://${{ steps.render-task.outputs.task-definition }} \
59+
--query 'taskDefinition.taskDefinitionArn' --output text)
60+
echo "TASK_DEF_ARN=$TASK_DEF_ARN" >> $GITHUB_ENV
61+
62+
- name: Scale service to 0 (stop current task)
63+
run: |
64+
aws ecs update-service \
65+
--cluster ${{ vars.ECS_CLUSTER }} \
66+
--service ${{ vars.ECS_SERVICE }} \
67+
--desired-count 0
68+
sleep 30
69+
70+
- name: Deploy new ECS task definition with count 1
71+
run: |
72+
aws ecs update-service \
73+
--cluster ${{ vars.ECS_CLUSTER }} \
74+
--service ${{ vars.ECS_SERVICE }} \
75+
--task-definition ${{ env.TASK_DEF_ARN }} \
76+
--desired-count 1
77+
78+
- name: Wait for ECS service to stabilize
79+
run: |
80+
aws ecs wait services-stable \
81+
--cluster ${{ vars.ECS_CLUSTER }} \
82+
--services ${{ vars.ECS_SERVICE }}

.github/workflows/test.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI-Test
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v3
17+
with:
18+
java-version: 17
19+
distribution: temurin
20+
21+
- name: Grant execute permission to Gradle
22+
run: chmod +x gradlew
23+
24+
- name: Build and Test with Gradle
25+
run: ./gradlew clean test
26+
27+
- name: Upload coverage to Codecov
28+
uses: codecov/codecov-action@v3
29+
with:
30+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ build/
1616
out/
1717
!**/src/main/**/out/
1818
!**/src/test/**/out/
19-
*.yaml
19+
application-prod.yaml
20+
.env
2021
*.logs
2122
### Eclipse ###
2223
.apt_generated

.idea/gradle.xml

-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)