Skip to content

🚀 secret keys add #61

🚀 secret keys add

🚀 secret keys add #61

Workflow file for this run

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` 파일 생성

Check failure on line 21 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy.yml

Invalid workflow file

You have an error in your yaml syntax on line 21
run: |
echo "${{ secrets.GCP_CREDENTIALS_JSON }}" | base64 --decode > nlp.json
- 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/nlp.json" \
-v $(pwd)/nlp.json:/app/nlp.json \
${{ secrets.DOCKER_USERNAME }}/learnmate:latest
EOF