Skip to content

chore: MySQL 연결 정보 추가 #27

chore: MySQL 연결 정보 추가

chore: MySQL 연결 정보 추가 #27

Workflow file for this run

name: Deploy to EC2 with Docker Compose
on:
pull_request:
branches:
- dev
env:
AWS_REGION: ap-northeast-2
DOCKER_HUB_REPOSITORY: baeeejw/jgs-spring-boot
working-directory: ./Server
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: gradlew에 실행 권한 부여
run: chmod +x gradlew
working-directory: ${{ env.working-directory }}
- name: 프로젝트 빌드
run: ./gradlew clean build -x test
working-directory: ${{ env.working-directory }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push Docker image
run: |
docker buildx build --push --tag ${{ env.DOCKER_HUB_REPOSITORY }}:latest .
working-directory: ${{ env.working-directory }}
- name: SSH into EC2 and deploy with Docker Compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SECRET }}
script: |
cd /home/ubuntu/spring-boot
echo "SPRING_DATASOURCE_URL=${{ secrets.SPRING_DATASOURCE_URL }}" > .env
echo "SPRING_DATASOURCE_USERNAME=${{ secrets.SPRING_DATASOURCE_USERNAME }}" >> .env
echo "SPRING_DATASOURCE_PASSWORD=${{ secrets.SPRING_DATASOURCE_PASSWORD }}" >> .env
echo "SPRING_JPA_HIBERNATE_DDL_AUTO=update" >> .env
echo "SPRING_REDIS_HOST=redis" >> .env
echo "SPRING_REDIS_PORT=6379" >> .env
docker-compose pull
docker-compose up -d