-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (65 loc) · 2.82 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
name: Deploy to EC2
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: 코드 체크아웃
uses: actions/checkout@v2
- name: Java 버전 설정
uses: actions/setup-java@v1
with:
java-version: '21'
- name: nlp.json 파일 생성
run: |
touch ./src/main/resources/nlp.json
echo "${{ secrets.GCP_CREDENTIALS_JSON }}" | base64 -d > ./src/main/resources/nlp.json
- name: 행동 요령 제안 프롬프트 생성
run: |
touch ./src/main/resources/action-tip-prompt.txt
echo "${{ secrets.ACTION_TIP_PROMPT }}" > ./src/main/resources/action-tip-prompt.txt
shell: bash
- name: Todo Guide 프롬프트 생성
run: |
touch ./src/main/resources/todo-guide-prompt.txt
echo "${{ secrets.TODO_GUIDE_PROMPT }}" > ./src/main/resources/todo-guide-prompt.txt
shell: bash
- name: 칭찬 카드 프롬프트 생성
run: |
touch ./src/main/resources/compliment-card-content-prompt.txt
echo "${{ secrets.COMPLIMENT_CARD_KEYWORD_PROMPT }}" > ./src/main/resources/compliment-card-keyword-prompt.txt
shell: bash
- name: Docker 로그인
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: JIB로 Docker 이미지 빌드 및 푸시
run: |
./gradlew jib --image=${{ secrets.DOCKER_USERNAME }}/learnmate:latest
- name: EC2에 Docker 컨테이너 배포
run: |
echo "${{ secrets.EC2_SSH_KEY }}" > ssh_key
chmod 600 ssh_key
ssh -o StrictHostKeyChecking=no -i ssh_key ec2-user@${{ secrets.EC2_HOST }} << 'EOF'
# 최신 이미지를 가져옴.
docker pull ${{ secrets.DOCKER_USERNAME }}/learnmate:latest
# 기존 컨테이너 중지 및 제거
docker stop learnmate-app || true
docker rm learnmate-app || true
# 새 컨테이너 실행
docker run -d \
--name learnmate-app \
-p 8080:8080 \
-e DATABASE_URL=${{ secrets.DATABASE_URL }} \
-e DATABASE_USERNAME=${{ secrets.DATABASE_USERNAME }} \
-e DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }} \
-e JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} \
-e JWT_ACCESS_TOKEN_EXPIRE=${{ secrets.JWT_ACCESS_TOKEN_EXPIRE }} \
-e JWT_REFRESH_TOKEN_EXPIRE=${{ secrets.JWT_REFRESH_TOKEN_EXPIRE }} \
-e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \
-e OPENAI_MODEL=${{ secrets.OPENAI_MODEL }} \
-e GCP_CREDENTIALS_LOCATION="/app/resources/nlp.json" \
${{ secrets.DOCKER_USERNAME }}/learnmate:latest
EOF