-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (102 loc) · 4.73 KB
/
user-service-ecr-ecs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: 'user-service upload ecr & ecs'
on:
push:
branches:
- master
paths:
- 'user-service/**'
- '.github/workflows/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Application Yaml
uses: microsoft/variable-substitution@v1
with:
files: user-service/src/main/resources/application.yml
env:
spring.data.redis.host: ${{ secrets.DOCS_SERVER_US_REDIS_HOST }}
spring.security.oauth2.client.registration.google.client-id: ${{ secrets.GOOGLE_CLIENT_ID }}
spring.security.oauth2.client.registration.google.client-secret: ${{ secrets.GOOGLE_CLIENT_SECRET }}
spring.security.oauth2.client.registration.naver.client-id: ${{ secrets.NAVER_CLIENT_ID }}
spring.security.oauth2.client.registration.naver.client-secret: ${{ secrets.NAVER_CLIENT_SECRET }}
spring.security.oauth2.client.registration.kakao.client-id: ${{ secrets.KAKAO_CLIENT_ID }}
spring.security.oauth2.client.registration.kakao.client-secret: ${{ secrets.KAKAO_CLIENT_SECRET }}
spring.security.oauth2.client.registration.apple.client-id: ${{ secrets.APPLE_CLIENT_ID }}
spring.security.oauth2.client.registration.apple.client-secret: ${{ secrets.APPLE_CLIENT_SECRET }}
spring.cloud.aws.credentials.access-key: ${{ secrets.AWS_ACCESS_KEY }}
spring.cloud.aws.credentials.secret-key: ${{ secrets.AWS_SECRET_KEY }}
spring.cloud.openfeign.client.config.bookClient.url: ${{ secrets.BOOK_CLIENT_URL }}
jwt.secretKey: ${{ secrets.JWT_SECRET_KEY }}
spring.cloud.aws.sns.credentials.access-key: ${{ secrets.AWS_SNS_ACCESS_KEY }}
spring.cloud.aws.sns.credentials.secret-key: ${{ secrets.AWS_SNS_SECRET_KEY }}
spring.cloud.aws.sns.region.static: ${{ secrets.AWS_SNS_REGION }}
spring.cloud.aws.sns.topic.arn: ${{ secrets.AWS_SNS_TOPIC_ARN }}
- name: Setup Bootstrap Yaml For Test
uses: microsoft/variable-substitution@v1
with:
files: user-service/src/main/resources/bootstrap.yml
env:
spring.profiles.active: test
- name: Setup Apple PrivateKey
working-directory: user-service
run: |
mkdir -p src/main/resources/apple
echo -e ${{ secrets.APPLE_AUTH_PRIVATE_KEY }} > src/main/resources/apple/AuthKey_8LCJC23RYD.p8
- name: Test with Gradle
working-directory: user-service
run: |
./gradlew test
- name: Setup Bootstrap Yaml
uses: microsoft/variable-substitution@v1
with:
files: user-service/src/main/resources/bootstrap.yml
env:
spring.profiles.active: prod
- name: Build with Gradle For Build
working-directory: user-service
run: |
./gradlew clean build -x test
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ECR_ECS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_ECR_ECS_SECRET_KEY }}
aws-region: ${{ secrets.ECR_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_USER_SERVICE_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
working-directory: user-service
run: |
docker build --platform amd64 -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ./user-service/task-definition.json
container-name: userService
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: userService-EcsService
cluster: MybraryCluster
codedeploy-deployment-group: DgpECS-MybraryCluster-userService-EcsService
codedeploy-appspec: ./user-service/appspec.yaml
wait-for-service-stability: true