Skip to content

πŸ› κΈ€μž 수 μ œν•œ ν•΄μ œ (#106) #81

πŸ› κΈ€μž 수 μ œν•œ ν•΄μ œ (#106)

πŸ› κΈ€μž 수 μ œν•œ ν•΄μ œ (#106) #81

Workflow file for this run

name: cd with Gradle
on:
push:
branches:
- main # main λΈŒλžœμΉ˜μ— push될 λ•Œ
permissions: write-all # ν…ŒμŠ€νŠΈ κ²°κ³Ό μž‘μ„±μ„ μœ„ν•΄ μ“°κΈ°κΆŒν•œ μΆ”κ°€
jobs:
build:
if: github.event.pull_request.merged == true || github.event_name == 'push' # PR merge λ˜λŠ” push일 λ•Œ μ‹€ν–‰
runs-on: ubuntu-latest # ν™˜κ²½
steps:
- name: Checkout repository
uses: actions/checkout@v3 # μ½”λ“œ 체크아웃 = κ°€μƒν™˜κ²½ 볡사
- name: Set up JDK 21
uses: actions/setup-java@v3 #jdk 컴파일러
with:
java-version: '21'
distribution: 'temurin' # μžλ°” 개발 ν‚€νŠΈ 배포판
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for Gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -x test #λΉŒλ“œ
- name: Ensure target directory exists
uses: appleboy/ssh-action@master # SSHλ₯Ό 톡해 λŒ€μƒ 디렉토리 생성
with:
username: ubuntu
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_KEY }}
script: |
mkdir -p /home/ubuntu/gather_back_end
- name: List build directory
run: ls -la build/libs
- name: Transfer Build File using SCP
uses: appleboy/scp-action@master # .jar 파일 원격 μ„œλ²„λ‘œ 볡사
with:
username: ubuntu
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_KEY }}
source: |
build/libs/gather_back_end-0.0.1-SNAPSHOT.jar
target: "/home/ubuntu/gather_back_end"
- name: Deploy using Docker Compose via SSH(Prod)
if: github.ref == 'refs/heads/main'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ubuntu
key: ${{ secrets.SSH_KEY }}
script_stop: true
script: |
cd /home/ubuntu/gather_back_end || exit 1 # 경둜 λ³€κ²½ μ‹€νŒ¨ μ‹œ μ’…λ£Œ
sudo docker compose down
sudo docker compose up --build -d