Skip to content

Commit 36f5364

Browse files
authored
Merge pull request #41 from boostcampwm-2024/cicd
feat: cicd workflow 작성
2 parents 5512015 + 47e3049 commit 36f5364

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/deploy.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# 작업 디렉토리 경로
4+
DIR="/home/root/app/autodocs"
5+
6+
# 디렉토리 확인
7+
if [ -d "$DIR" ]; then
8+
echo "$DIR 디렉토리가 존재합니다. 최신 버전으로 업데이트 중..."
9+
cd "$DIR"
10+
git pull
11+
else
12+
echo "$DIR 디렉토리가 존재하지 않습니다. 클론 중..."
13+
git clone https://github.com/boostcampwm-2024/web15-OctoDocs.git "$DIR"
14+
cd "$DIR"
15+
fi
16+
17+
# backend 디렉토리로 이동
18+
cd backend
19+
20+
# 기존 프로세스 확인 및 종료
21+
echo "기존 프로세스 확인 중..."
22+
EXISTING_PID=$(lsof -ti :3000) # 여기서 포트 번호는 필요에 따라 조정
23+
24+
if [ -n "$EXISTING_PID" ]; then
25+
echo "기존 프로세스(PID: $EXISTING_PID) 종료 중..."
26+
kill -9 "$EXISTING_PID"
27+
echo "기존 프로세스가 종료되었습니다."
28+
else
29+
echo "실행 중인 프로세스가 없습니다."
30+
fi
31+
32+
# 의존성 설치 및 애플리케이션 시작
33+
echo "의존성 설치 중..."
34+
npm install
35+
36+
echo "애플리케이션 시작 중..."
37+
nohup npm start &

.github/workflows/main.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Create Directory on Remote Server
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
create-directory:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# 코드 체크아웃
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
# Node.js 설치
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: "23"
22+
# 패키지 설치 및 React 빌드
23+
- name: Install dependencies and build
24+
run: |
25+
cd frontend
26+
npm install
27+
npm run build
28+
29+
# aws cli를 통해 ncloud object storage 업로드
30+
- name: Configure AWS credentials
31+
uses: aws-actions/configure-aws-credentials@v3
32+
with:
33+
aws-access-key-id: ${{ secrets.NCLOUD_ACCESS_KEY_ID }}
34+
aws-secret-access-key: ${{ secrets.NCLOUD_SECRET_ACCESS_KEY }}
35+
36+
- name: Upload files to S3
37+
run: |
38+
aws --endpoint-url=http://octodocs.s3-website.kr.object.ncloudstorage.com s3 cp ./frontend/dist s3://octodocs --recursive
39+
40+
# 패키지 설치 및 Nest.js 빌드
41+
- name: Install dependencies and build
42+
run: |
43+
cd backend
44+
npm install
45+
npm run build
46+
47+
# 배포용 쉘 스크립트 파일 전송
48+
- name: Copy deploy.sh to remote server
49+
uses: appleboy/[email protected]
50+
with:
51+
host: ${{ secrets.REMOTE_IP }}
52+
username: ${{ secrets.REMOTE_USER }}
53+
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
54+
source: ./deploy.sh
55+
target: /home/root/deploy.sh

0 commit comments

Comments
 (0)