Skip to content

Commit 815e2bd

Browse files
committed
refactor: CI turbo로 프론트, 백엔드 동시 수행
1 parent 3196147 commit 815e2bd

File tree

1 file changed

+57
-40
lines changed

1 file changed

+57
-40
lines changed

.github/workflows/main.yml

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,64 @@
1+
# CI가 끝난 뒤 CD 실행
12
name: Create Directory on Remote Server
2-
3+
on:
4+
workflow_run:
5+
workflows:
6+
- "OctoDocs CI Pipeline"
7+
types:
8+
- completed
39
on:
410
push:
511
branches:
6-
- develop
12+
- be-feature-#173
713

814
jobs:
9-
frontend-CD:
10-
runs-on: ubuntu-latest
15+
# frontend-CD:
16+
# runs-on: ubuntu-latest
1117

12-
steps:
13-
# 코드 체크아웃
14-
- name: Checkout code
15-
uses: actions/checkout@v3
18+
# steps:
19+
# # 코드 체크아웃
20+
# - name: Checkout code
21+
# uses: actions/checkout@v3
1622

17-
# .env 파일 생성 후 붙여넣기
18-
- name: Create .env file
19-
run: |
20-
echo "${{secrets.DEVELOPMENT_FE_ENV}}" > ./frontend/.env
23+
# # .env 파일 생성 후 붙여넣기
24+
# - name: Create .env file
25+
# run: |
26+
# echo "${{secrets.DEVELOPMENT_ENV}}" > ./apps/frontend/.env
27+
# echo "${{secrets.DEVELOPMENT_ENV}}" > ./apps/backend/.env
2128

22-
# Node.js 설치
23-
- name: Set up Node.js
24-
uses: actions/setup-node@v3
25-
with:
26-
node-version: "23"
27-
# 패키지 설치 및 React 빌드
28-
- name: Install dependencies and build
29-
run: |
30-
cd frontend
31-
npm install
32-
npm run build
29+
# # Node.js 설치
30+
# - name: Set up Node.js
31+
# uses: actions/setup-node@v3
32+
# with:
33+
# node-version: "23"
34+
# 패키지 설치 및 빌드
35+
# - name: Install dependencies and build
36+
# run: |
37+
# yarn install
38+
# yarn build
3339

3440
# aws cli를 통해 ncloud object storage 업로드
35-
- name: Configure AWS credentials
36-
env:
37-
NCLOUD_ACCESS_KEY_ID: ${{ secrets.NCLOUD_ACCESS_KEY_ID }}
38-
NCLOUD_SECRET_ACCESS_KEY: ${{ secrets.NCLOUD_SECRET_ACCESS_KEY }}
39-
run: |
40-
aws configure set aws_access_key_id $NCLOUD_ACCESS_KEY_ID
41-
aws configure set aws_secret_access_key $NCLOUD_SECRET_ACCESS_KEY
42-
aws configure set region ap-northeast-2
43-
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp ./frontend/dist s3://octodocs/ --recursive --debug
41+
# - name: Configure AWS credentials
42+
# env:
43+
# NCLOUD_ACCESS_KEY_ID: ${{ secrets.NCLOUD_ACCESS_KEY_ID }}
44+
# NCLOUD_SECRET_ACCESS_KEY: ${{ secrets.NCLOUD_SECRET_ACCESS_KEY }}
45+
# run: |
46+
# aws configure set aws_access_key_id $NCLOUD_ACCESS_KEY_ID
47+
# aws configure set aws_secret_access_key $NCLOUD_SECRET_ACCESS_KEY
48+
# aws configure set region ap-northeast-2
49+
# aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp ./frontend/dist s3://octodocs/ --recursive --debug
4450
backend-CD:
4551
runs-on: ubuntu-latest
4652

4753
steps:
4854
# 코드 체크아웃
49-
- name: Checkout code
50-
uses: actions/checkout@v3
55+
# - name: Checkout code
56+
# uses: actions/checkout@v3
5157

52-
# .env 파일 생성 후 붙여넣기
53-
- name: Create .env file
54-
run: |
55-
echo "${{secrets.DEVELOPMENT_ENV}}" > ./.env
58+
# # .env 파일 생성 후 붙여넣기
59+
# - name: Create .env file
60+
# run: |
61+
# echo "${{secrets.DEVELOPMENT_ENV}}" > ./.env
5662
# sh 실행
5763
- name: Connect to Remote Server and Run Commands
5864
env:
@@ -85,6 +91,9 @@ jobs:
8591
yarn -v
8692
yarn install
8793
94+
# build
95+
yarn build
96+
8897
# Check and kill existing process
8998
EXISTING_PID=$(lsof -ti :3000)
9099
@@ -104,15 +113,23 @@ jobs:
104113
username: ${{ secrets.REMOTE_USER }}
105114
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
106115
source: ./.env
107-
target: /home/root/app/octodocs
116+
target: /home/root/app/octodocs/apps/backend
117+
- name: Copy .env to remote server
118+
uses: appleboy/scp-action@master
119+
with:
120+
host: ${{ secrets.REMOTE_DEV_IP }}
121+
username: ${{ secrets.REMOTE_USER }}
122+
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
123+
source: ./.env
124+
target: /home/root/app/octodocs/apps/frontend
108125
# yarn start
109126
- name: yarn start
110127
env:
111128
REMOTE_HOST: ${{ secrets.REMOTE_DEV_IP }}
112129
REMOTE_USER: ${{ secrets.REMOTE_USER }}
113130
SSH_KEY: ${{ secrets.REMOTE_PRIVATE_KEY }}
114131
run: |
115-
ssh -o StrictHostKeyChecking=no $REMOTE_USER@$REMOTE_HOST "cd /home/root/app/octodocs; nohup yarn start > nohup.out 2> nohup.err < /dev/null &"
132+
ssh -o StrictHostKeyChecking=no $REMOTE_USER@$REMOTE_HOST "nohup node /home/root/app/octodocs/apps/backend/dist/main.js > nohup.out 2> nohup.err < /dev/null &"
116133
117134
# # 배포용 쉘 스크립트 파일 전송
118135
# - name: Copy deploy.sh to remote server

0 commit comments

Comments
 (0)