fix: gradle.yml 명령어수정 #327
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: 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: 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 connectingstarlive | |
sudo docker pull ${{ secrets.DOCKER_REPO_LIVE }} | |
docker-compose up -d | |
docker image prune -f |