Skip to content

Merge pull request #24 from venus-y/feat/blind-retro #20

Merge pull request #24 from venus-y/feat/blind-retro

Merge pull request #24 from venus-y/feat/blind-retro #20

Workflow file for this run

name: Deploy dev-be to GCP VM
on:
push:
branches:
- dev-be
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# 1. 코드 체크아웃
- name: Checkout dev-be branch
uses: actions/checkout@v4
# 2. JDK 21 설치
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
# 3. application-secret.yaml 생성
- name: Create application-secret.yaml
run: |
echo "${{ secrets.APPLICATION_SECRET_YAML }}" \
> src/main/resources/application-secret.yaml
# 4. Gradle 빌드
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew clean build -x test
# 5. JAR 이름 통일
- name: Rename jar
run: |
mv build/libs/*SNAPSHOT.jar build/libs/app.jar
# 6. 원격 서버 사전 점검 (디렉터리/디스크)
- name: Pre-check remote server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.GCP_HOST }}
username: ${{ secrets.GCP_USERNAME }}
key: ${{ secrets.GCP_PRIVATE_KEY }}
port: 2222
script_stop: true
script: |
echo "[CHECK] Disk space"
df -h /
echo "[CHECK] Ensure directories"
mkdir -p /home/retrospection1234/spring-boot/review_store_backend/build/libs
# 7. JAR 전송 (임시 파일명)
- name: Copy jar to GCP VM
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.GCP_HOST }}
username: ${{ secrets.GCP_USERNAME }}
key: ${{ secrets.GCP_PRIVATE_KEY }}
port: 2222
source: build/libs/app.jar
target: /home/***/spring-boot/review_store_backend
overwrite: true
# 8. 원격 서버 배포 (교체 + 재시작)
- name: Deploy & Restart on GCP VM
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.GCP_HOST }}
username: ${{ secrets.GCP_USERNAME }}
key: ${{ secrets.GCP_PRIVATE_KEY }}
port: 2222
script_stop: true
script: |
cd /home/***/spring-boot/review_store_backend
echo "[DEPLOY] Stop existing process (by port)"
fuser -k -n tcp 8080 || true
sleep 2
echo "[DEPLOY] Start new process"
nohup java -jar build/libs/app.jar > output.log 2>&1 &
echo "[VERIFY] Process running"
sleep 5
ps -ef | grep "java -jar build/libs/app.jar" | grep -v grep || true