-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (141 loc) · 5.01 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
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
name: learnsmate-service
permissions:
contents: read
pull-requests: write
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'corretto'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: LearnsMate
shell: bash
- name: Install envsubst
run: sudo apt-get install -y gettext
- name: Generate application.yml.template
working-directory: LearnsMate
run: |
mkdir -p src/main/resources
cat > src/main/resources/application.yml.template <<EOL
server:
port: 5000
management:
endpoints:
web:
exposure:
include: health
endpoint:
health:
show-details: always
spring:
application:
name: learnsmate
datasource:
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:mariadb://\${RDS_HOSTNAME}:\${RDS_PORT}/\${RDS_DB_NAME}
username: \${RDS_USERNAME}
password: \${RDS_PASSWORD}
jpa:
generate-ddl: false
show-sql: true
database: mysql
properties:
hibernate:
'[format_sql]': true
mail:
host: \${SPRING_MAIL_SMTP_HOST}
username: \${SMTP_USERNAME}
password: \${SMTP_PASSWORD}
port: \${SMTP_PORT}
properties:
mail:
smtp:
auth: true
starttls:
enable: true
openai:
model: gpt-4o
secret-key: \${SECRET_KEY}
token:
expiration_time: 43200000
secret: \${TOKEN_SECRET}
EOL
- name: Set application.yml with Secrets
working-directory: LearnsMate
run: |
envsubst < src/main/resources/application.yml.template > src/main/resources/application.yml
echo "Generated application.yml:"
cat src/main/resources/application.yml
env:
RDS_HOSTNAME: ${{ secrets.RDS_HOSTNAME }}
RDS_PORT: ${{ secrets.RDS_PORT }}
RDS_DB_NAME: ${{ secrets.RDS_DB_NAME }}
RDS_USERNAME: ${{ secrets.RDS_USERNAME }}
RDS_PASSWORD: ${{ secrets.RDS_PASSWORD }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
TOKEN_SECRET: ${{ secrets.JWT_SECRET }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SPRING_MAIL_SMTP_HOST: ${{ secrets.SPRING_MAIL_SMTP_HOST }}
- name: Build with Gradle
run: ./gradlew clean build -x test
working-directory: LearnsMate
shell: bash
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"
- name: Show Current Time
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}"
shell: bash
- name: Generate deployment package
working-directory: LearnsMate
run: |
mkdir -p deploy
cp build/libs/*.jar deploy/application.jar
cp Procfile deploy/Procfile
cp -r .ebextensions deploy/.ebextensions
cp -r .platform deploy/.platform
cd deploy && zip -r deploy.zip .
- name: Deploy to Beanstalk1
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: intbyte-env
environment_name: Intbyte-env
version_label: github-action-${{steps.current-time.outputs.formattedTime}}
region: ap-northeast-2
deployment_package: LearnsMate/deploy/deploy.zip
use_existing_version_if_available: false
wait_for_deployment: true
wait_for_environment_recovery: 300
- name: Deploy to Beanstalk2
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: intbyte-env2
environment_name: Intbyte-env2
version_label: github-action-${{steps.current-time.outputs.formattedTime}}
region: ap-northeast-2
deployment_package: LearnsMate/deploy/deploy.zip
use_existing_version_if_available: false
wait_for_deployment: true
wait_for_environment_recovery: 300