♻️refactor: v1, v2 구분을 위한 리팩토링[#110] #46
This file contains hidden or 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: Deploy with Lightsail | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: SSH로 Lightsail에 접속합니다. | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_PRIVATE_KEY }} | |
| script_stop: true | |
| script: | | |
| set -euo pipefail | |
| APP_DIR="/home/ubuntu/WeGo_BackEnd" | |
| BRANCH="main" | |
| APP_PORT="8080" | |
| cd "$APP_DIR" | |
| echo "[INFO] Git 업데이트..." | |
| git fetch --all --prune | |
| git checkout "$BRANCH" | |
| git reset --hard "origin/$BRANCH" | |
| echo "[INFO] 기존 앱 종료 (포트 $APP_PORT)..." | |
| sudo fuser -k -n tcp "$APP_PORT" || true | |
| echo "[INFO] Gradle 빌드..." | |
| chmod +x gradlew | |
| ./gradlew clean build -x test | |
| echo "[INFO] JAR 찾는 중..." | |
| JAR="build/libs/wegobackend-0.0.1-SNAPSHOT.jar" | |
| echo "[INFO] 사용 JAR: $JAR" | |
| echo "[INFO] 애플리케이션 시작..." | |
| nohup java -jar "$JAR" --server.port="$APP_PORT" > ./output.log 2>&1 & | |
| echo "[INFO] 앱이 포트 $APP_PORT 에서 시작되었습니다." |