Skip to content

Feature: grdale 수정 1 #323

Feature: grdale 수정 1

Feature: grdale 수정 1 #323

Workflow file for this run

name: CD with Gradle
on:
push:
branches: [ "live" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.GIT_TOKEN }}
# Ensure submodules are on the correct branch (live)
- name: Ensure Submodules are on Live Branch
run: |
git submodule foreach --recursive 'git fetch origin live || true'
git submodule foreach --recursive 'git checkout -b live origin/live || true'
git submodule foreach --recursive 'git pull origin live || true'
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: "adopt"
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -x test
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_ID_LIVE }}
password: ${{ secrets.DOCKER_PWD_LIVE }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKER_REPO_LIVE }}
- name: Deploy to server
uses: appleboy/ssh-action@master
id: deploy
with:
host: ${{ secrets.HOST_LIVE }}
username: ec2-user
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.PORT }}
envs: GITHUB_SHA
script: |
sudo docker rm -f $(docker ps -aq) || true # 모든 컨테이너 제거
sudo docker pull ${{ secrets.DOCKER_REPO_LIVE }}
docker-compose up -d
docker image prune -f