-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (108 loc) · 5.24 KB
/
deploy.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Deploy to Amazon EC2
on:
push:
branches:
- release
env:
AWS_REGION: ap-northeast-2
S3_BUCKET_NAME: ideac-github-actions-s3-bucket
CODE_DEPLOY_APPLICATION_NAME: ideac-codedeploy-app
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: ideac-codedeploy-deployment-group
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME2: ideac-admin-codedeploy-deployment-group
jobs:
deploy_core_admin:
name: Deploy Core and Admin modules
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set IDEAC-CORE YML
run: |
mkdir -p ideac-core/src/main/resources
echo "${{ secrets.APPLICATION_MAIL_YML }}" | base64 --decode > ideac-core/src/main/resources/application-mail.yml
mkdir -p ideac-core/src/main/resources/oauth2
echo "${{ secrets.APPLICATION_OAUTH2_YML }}" | base64 --decode > ideac-core/src/main/resources/oauth2/application-oauth2.yml
- name: Set IDEAC-ADMIN YML
run: |
mkdir -p ideac-admin/src/main/resources
echo "${{ secrets.ADMIN_APPLICATION_YML }}" | base64 --decode > ideac-admin/src/main/resources/application.yml
echo "${{ secrets.ADMIN_APPLICATION_SWAGGER_YML }}" | base64 --decode > ideac-admin/src/main/resources/application-swagger.yml
- name: Build Core and Admin modules with Gradle
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
with:
arguments: clean build -x test
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
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: Upload Core and Admin modules to AWS S3
run: |
cp -r ideac-admin/appspec.yml .
cp -r ideac-admin/scripts .
# ideac-core와 ideac-admin 모듈을 함께 압축하여 업로드할 파일을 생성합니다.
zip -r $GITHUB_SHA-core-admin.zip ideac-core ideac-admin appspec.yml scripts
# 생성한 파일을 S3로 업로드합니다.
aws s3 cp $GITHUB_SHA-core-admin.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA-core-admin.zip
- name: Deploy Core and Admin modules to AWS EC2 from S3
run: |
aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME2 }} \
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA-core-admin.zip,bundleType=zip
deploy_core_user:
name: Deploy Core and User modules
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set IDEAC-CORE YML
run: |
mkdir -p ideac-core/src/main/resources
echo "${{ secrets.APPLICATION_MAIL_YML }}" | base64 --decode > ideac-core/src/main/resources/application-mail.yml
mkdir -p ideac-core/src/main/resources/oauth2
echo "${{ secrets.APPLICATION_OAUTH2_YML }}" | base64 --decode > ideac-core/src/main/resources/oauth2/application-oauth2.yml
- name: Set IDEAC-USER YML
run: |
mkdir -p ideac-user/src/main/resources
echo "${{ secrets.APPLICATION_YML }}" | base64 --decode > ideac-user/src/main/resources/application.yml
echo "${{ secrets.APPLICATION_SWAGGER_YML }}" | base64 --decode > ideac-user/src/main/resources/application-swagger.yml
- name: Build Core and User modules with Gradle
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
with:
arguments: clean build -x test
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
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: Upload Core and User modules to AWS S3
run: |
cp -r ideac-user/appspec.yml .
cp -r ideac-user/scripts .
# ideac-core와 ideac-user 모듈을 함께 압축하여 업로드할 파일을 생성합니다.
zip -r $GITHUB_SHA-core-user.zip ideac-core ideac-user appspec.yml scripts
# 생성한 파일을 S3로 업로드합니다.
aws s3 cp $GITHUB_SHA-core-user.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA-core-user.zip
- name: Deploy Core and User modules to AWS EC2 from S3
run: |
aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA-core-user.zip,bundleType=zip