-
Notifications
You must be signed in to change notification settings - Fork 3
131 lines (106 loc) · 4.18 KB
/
main.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
name: ReviewTwits Server CI/CD
on:
push:
branches:
- main
- develop
env:
S3_BUCKET_NAME: reviewtwits
S3_BUCKET_NAME2: reviewtwits2
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Make application.properties
run: |
cd ./src/main/resources
echo "${{ secrets.DB_SECRET_INFORMATION }}" >> ./application.properties
cat ./application.properties
shell: bash
- name: Make email.properties
run: |
cd ./src/main/resources
echo "${{ secrets.EMAIL_CONFIG_INFO }}" >> ./email.properties
cat ./email.properties
shell: bash
- name: Make s3.properties
run: |
cd ./src/main/resources
echo "${{ secrets.AWS_S3 }}" >> ./s3.properties
cat ./s3.properties
shell: bash
- name: Setup Redis
run: sudo apt-get install -y redis-server
- name: Install Google Chrome for Selenium
run: |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
# - name : Setup MariaDB
# uses: getong/mariadb-action@v1.1
# with:
# character set server: 'utf8mb4' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
# mariadb version: '10.6.8' # Optional, default value is "latest". The version of the MariaDB
# mysql database: 'reviewtwits' # Optional, default value is "test". The specified database which will be create
# # mysql root password: ${{ secrets.MARIADB_PASSWORD }} # Required if "mysql user" is empty, default is empty. The root superuser password
# mysql user: ${{ secrets.MARIADB_USERNAME}} # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
# mysql password: ${{ secrets.MARIADB_PASSWORD }} # Required if "mysql user" exists. The password for the "mysql user"
- name: Build with Gradle
env:
auto-ddl: create
run: ./gradlew clean build
# 디렉토리 생성
- name: Make Directory
run: mkdir -p deploy
# Jar 파일 복사
- name: Copy Jar
run: cp ./build/libs/*.jar ./deploy
# appspec.yml 파일 복사
- name: Copy appspec.yml
run: cp appspec.yml ./deploy
# script files 복사
- name: Copy script
run: cp ./scripts/*.sh ./deploy
- name: Make zip file
run: zip -r ./reviewtwits.zip ./deploy
shell: bash
- 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: ap-northeast-2
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./reviewtwits.zip s3://$S3_BUCKET_NAME/reviewtwits.zip
# Deploy
- name: Code Deploy
run: |
aws deploy create-deployment \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--application-name reviewtwits \
--deployment-group-name reviewtwits-group \
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=reviewtwits.zip
# 두번째 서버에도 배포
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID2 }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY2 }}
aws-region: ap-northeast-2
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./reviewtwits.zip s3://$S3_BUCKET_NAME2/reviewtwits.zip
# Deploy
- name: Code Deploy
run: |
aws deploy create-deployment \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--application-name reviewtwits \
--deployment-group-name reviewtwits-group \
--s3-location bucket=$S3_BUCKET_NAME2,bundleType=zip,key=reviewtwits.zip