feature: 로깅 추가 (#70) #40
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 production | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- develop | |
- main | |
jobs: | |
build-docker-image-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.SUBMODULE_TOKEN }} | |
submodules: true | |
- name: Setup JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'gradle' | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Build JAR | |
run: ./gradlew bootJar -Dspring.profiles.active=prod | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
file: ./Dockerfile | |
tags: ${{ secrets.DOCKER_HUB_REPOSITORY }}:prod | |
deployment: | |
runs-on: ubuntu-latest | |
needs: [ build-docker-image-and-push ] | |
steps: | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.AWS_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.AWS_SSH_KEY }} | |
script: | | |
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
cd api/bin/ | |
sudo docker compose down --rmi all | |
sudo docker compose up -d |