Skip to content

📝 README 영문 수정 #13

📝 README 영문 수정

📝 README 영문 수정 #13

Workflow file for this run

name: Deploy
on:
push
env:
REPO: lyf-jarvis-back
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Set Yaml
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/application-prod.yml
env:
spring.datasource.url: ${{ secrets.DB_HOST }}
spring.datasource.username: admin
spring.datasource.password: ${{ secrets.DB_PASSWORD }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context : .
file: Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO }}:latest
deploy-to-ec2:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_SSH_USER }}
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
script: |
CONTAINER_ID=$(sudo docker ps -q --filter "publish=8080-8081")
if [ ! -z "$CONTAINER_ID" ]; then
sudo docker stop $CONTAINER_ID || true
sudo docker rm $CONTAINER_ID || true
fi
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/lyf-jarvis-back:latest
sudo docker run -d --name lyf-jarvis-back-${{ github.sha }} -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/lyf-jarvis-back:latest