forked from wuzuzu/wuzuzu
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (135 loc) · 7.55 KB
/
CICD.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Build and Deploy to EC2
on:
pull_request:
branches: [ "main" ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'adopt'
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
npm: 'latest'
- name: make .env
run: |
cd src/main/wuzuzu_fe
touch ./.env
shell: bash
- name: Generate .env
run: |
echo "REACT_APP_IMP=$REACT_APP_IMP" >> ./.env
echo "REACT_APP_IMP_KAKAO=$REACT_APP_IMP_KAKAO" >> ./.env
shell: bash
env:
REACT_APP_IMP: ${{ secrets.REACT_APP_IMP }}
REACT_APP_IMP_KAKAO: ${{ secrets.REACT_APP_IMP_KAKAO }}
- name: Install frontend dependencies
run: |
npm install
cd ..
- name: make application.properties
run: |
mkdir -p ./resources
cd ./resources
touch ./application.properties
shell: bash
- name: Generate application.properties
run: |
echo "spring.application.name=wuzuzu" > ./src/main/resources/application.properties
echo "spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver" >> ./src/main/resources/application.properties
echo "spring.datasource.url=$MYSQL_URL" >> ./src/main/resources/application.properties
echo "spring.datasource.username=$MYSQL_USERNAME" >> ./src/main/resources/application.properties
echo "spring.datasource.password=$MYSQL_PASSWORD" >> ./src/main/resources/application.properties
echo "spring.jpa.hibernate.ddl-auto=update" >> ./src/main/resources/application.properties
echo "spring.jpa.properties.hibernate.show_sql=false" >> ./src/main/resources/application.properties
echo "spring.jpa.properties.hibernate.format_sql=true" >> ./src/main/resources/application.properties
echo "spring.jpa.properties.hibernate.use_sql_comments=true" >> ./src/main/resources/application.properties
echo "spring.data.redis.host=$REDIS_URL" >> ./src/main/resources/application.properties
echo "spring.data.redis.port=$REDIS_PORT" >> ./src/main/resources/application.properties
echo "cloud.aws.region.static=$AWS_REGION" >> ./src/main/resources/application.properties
echo "cloud.aws.stack.auto-=false" >> ./src/main/resources/application.properties
echo "cloud.aws.s3.credentials.accessKey=$S3_ACCESS_KEY" >> ./src/main/resources/application.properties
echo "cloud.aws.s3.credentials.secretKey=$S3_ACCESS_SECRET_KEY" >> ./src/main/resources/application.properties
echo "cloud.aws.s3.bucket=$S3_BUCKET_NAME" >> ./src/main/resources/application.properties
echo "upload.path=$S3_UPLOAD_PATH" >> ./src/main/resources/application.properties
echo "defaultImage.path=$S3_DEFAULT_IMAGE_PATH" >> ./src/main/resources/application.properties
echo "jwt.secret.key=$JWT_SECRET_KEY" >> ./src/main/resources/application.properties
echo "spring.mail.host=$EMAIL_HOST" >> ./src/main/resources/application.properties
echo "spring.mail.port=$EMAIL_PORT" >> ./src/main/resources/application.properties
echo "spring.mail.username=$EMAIL_USERNAME" >> ./src/main/resources/application.properties
echo "spring.mail.password=$EMAIL_PASSWORD" >> ./src/main/resources/application.properties
echo "spring.mail.properties.mail.smtp.auth=true" >> ./src/main/resources/application.properties
echo "spring.mail.properties.mail.smtp.starttls.enable=true" >> ./src/main/resources/application.properties
echo "spring.mail.properties.mail.smtp.starttls.required=true" >> ./src/main/resources/application.properties
echo "spring.mail.properties.mail.smtp.connectiontimeout=5000" >> ./src/main/resources/application.properties
echo "spring.mail.properties.mail.smtp.timeout=5000" >> ./src/main/resources/application.properties
echo "spring.mail.properties.mail.smtp.writetimeout=5000" >> ./src/main/resources/application.properties
echo "spring.mail.auth-code-expiration-millis=1800000" >> ./src/main/resources/application.properties
echo "iamport.key=$IAMPORT_KEY" >> ./src/main/resources/application.properties
echo "iamport.secret=$IAMPORT_SECRET_KEY" >> ./src/main/resources/application.properties
echo "iamport.code=$IAMPORT_CODE" >> ./src/main/resources/application.properties
echo "cloud.aws.sqs.queue.name=$SQS_QUEUE_NAME" >> ./src/main/resources/application.properties
echo "cloud.aws.sqs.queue.url=$SQS_QUEUE_URL" >> ./src/main/resources/application.properties
cd ../../..
shell: bash
env:
MYSQL_URL: ${{ secrets.MYSQL_URL }}
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
REDIS_URL: ${{ secrets.REDIS_URL }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
AWS_REGION: ${{ secrets.AWS_REGION }}
# AmazonS3FullAccess 권한을 가진 IAM 의 액세스 키
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_ACCESS_SECRET_KEY: ${{ secrets.S3_ACCESS_SECRET_KEY }}
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
S3_UPLOAD_PATH: ${{ secrets.S3_UPLOAD_PATH }}
S3_DEFAULT_IMAGE_PATH: ${{ secrets.S3_DEFAULT_IMAGE_PATH }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
EMAIL_HOST: ${{ secrets.EMAIL_HOST }}
EMAIL_PORT: ${{ secrets.EMAIL_PORT }}
EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
# AmazonSQSFullAccess 권한을 가진 IAM 의 액세스 키
IAMPORT_KEY: ${{ secrets.IAMPORT_KEY }}
IAMPORT_SECRET_KEY: ${{ secrets.IAMPORT_SECRET_KEY }}
IAMPORT_CODE: ${{ secrets.IAMPORT_CODE }}
SQS_QUEUE_NAME: ${{ secrets.SQS_QUEUE_NAME }}
SQS_QUEUE_URL: ${{ secrets.SQS_QUEUE_URL }}
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Build and Test
run: ./gradlew build test
- name: Make Zip File
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
# AWSCodeDeployFullAccess 권한을 가진 IAM 의 액세스 키
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_PRIVATE_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/wuzuzu/$GITHUB_SHA.zip
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
- name: Code Deploy To EC2 instance
run: aws deploy create-deployment
--application-name $CODE_DEPLOY_APP_NAME
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name "$DEPLOYMENT_GROUP_NAME"
--s3-location bucket="${{ S3_BUCKET_NAME }}",bundleType=zip,key=wuzuzu/$GITHUB_SHA.zip
env:
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
CODE_DEPLOY_APP_NAME: ${{ CODE_DEPLOY_APP_NAME }}
DEPLOYMENT_GROUP_NAME: ${{ DEPLOYMENT_GROUP_NAME }}