File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy with Lightsail
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : SSH로 Lightsail에 접속합니다.
13+ 14+ with :
15+ host : ${{ secrets.EC2_HOST }}
16+ username : ${{ secrets.EC2_USERNAME }}
17+ key : ${{ secrets.EC2_PRIVATE_KEY }}
18+ script_stop : true
19+ script : |
20+ set -euo pipefail
21+
22+ APP_DIR="/home/ubuntu/WeGo_BackEnd"
23+ BRANCH="main"
24+ APP_PORT="8080"
25+
26+ cd "$APP_DIR"
27+
28+ echo "[INFO] Git 업데이트..."
29+ git fetch --all --prune
30+ git checkout "$BRANCH"
31+ git reset --hard "origin/$BRANCH"
32+
33+ echo "[INFO] 기존 앱 종료 (포트 $APP_PORT)..."
34+ sudo fuser -k -n tcp "$APP_PORT" || true
35+
36+ echo "[INFO] Gradle 빌드..."
37+ chmod +x gradlew
38+ ./gradlew clean build -x test
39+
40+ echo "[INFO] JAR 찾는 중..."
41+ JAR="$(ls build/libs/*SNAPSHOT.jar | head -n 1 || true)"
42+ if [ -z "$JAR" ]; then
43+ echo "[ERROR] build/libs/*SNAPSHOT.jar 파일을 찾지 못했습니다."
44+ ls -al build/libs || true
45+ exit 1
46+ fi
47+ echo "[INFO] 사용 JAR: $JAR"
48+
49+ echo "[INFO] 애플리케이션 시작..."
50+ nohup java -jar "$JAR" --server.port="$APP_PORT" > ./output.log 2>&1 &
51+ echo "[INFO] 앱이 포트 $APP_PORT 에서 시작되었습니다."
You can’t perform that action at this time.
0 commit comments