Skip to content

refactor: statistics에서 return dto 수정 #55

refactor: statistics에서 return dto 수정

refactor: statistics에서 return dto 수정 #55

name: Deploy Spring Application to EC2
# test/dev에 대한 브랜치 push가 수행되었을 때 동작
on:
push:
branches: [ "dev-be" ]
# 워크플로우가 저장소의 콘텐츠를 읽을 수 있는 권한을 갖도록 설정
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
- name: Make application.yaml
run: |
cd ./BE/Blog/src/main
mkdir -p resources
cd resources
touch application.yaml
echo "${{ secrets.YAML }}" > application.yaml
shell: bash
- name: Grant execute permission for gradlew
run: |
cd ./BE/Blog
chmod +x gradlew
- name: Build with Gradle
run: |
cd ./BE/Blog
./gradlew clean build -x test
# Dockerfile을 통해 이미지를 빌드하고, 이를 Docker repo로 push
- name: Docker build & push to Docker repo
run: |
cd ./BE/Blog
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
docker build --build-arg DEPENDENCY=build/dependency -t ${{ secrets.DOCKER_ID }}/${{ secrets.DOCKER_REPO }} --platform linux/amd64 .
docker push ${{ secrets.DOCKER_ID }}/${{ secrets.DOCKER_REPO }}
# 서버에 접속 후 Docker 이미지 가져와서 배포
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
echo ${{ secrets.DOCKER_PASSWORD }} | sudo docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
sudo docker pull ${{ secrets.DOCKER_ID }}/${{ secrets.DOCKER_REPO }}:latest
# 기존에 실행 중인 컨테이너 중지 및 삭제
if [ $(sudo docker ps -q -f "name=blog-server") ]; then
sudo docker stop blog-server
sudo docker rm -f blog-server
fi
# 새로운 컨테이너 실행
sudo docker run -d -p 8080:8080 --name blog-server ${{ secrets.DOCKER_ID }}/${{ secrets.DOCKER_REPO }}:latest