!hotfix: gcp credentials config #85
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |