-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ | |
|
||
참고해야할 부분 작성 | ||
|
||
## 💌 빌드 완료 스크린샷 | ||
|
||
`npm run build` 실행 후 에러 없는 화면을 캡쳐하여 보여주세요! | ||
|
||
## 💬 참고 사항 | ||
|
||
참고해야할 부분 작성 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,61 @@ | ||
name: Deploy to Server | ||
name: Deploy to EC2 server | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop # develop 브랜치에 푸시될 때마다 실행 | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
name: Build and Deploy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Execute deploy script on EC2 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USER }} | ||
key: ${{ secrets.SERVER_SSH_KEY }} | ||
port: 22 | ||
script: | | ||
cd ~/STUDIO-EYE-WEB-PROMOTION | ||
git pull origin main | ||
sudo systemctl restart nginx | ||
# 1. Checkout the code from the repository (빌드 폴더는 무시됨) | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# 2. Set up Node.js environment | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.19.1' # 서버에서 사용 중인 Node.js 버전 | ||
|
||
# 3. Install the dependencies | ||
- name: Install dependencies | ||
run: npm install | ||
|
||
# 4. Build the project | ||
- name: Build project | ||
run: CI=false npm run build # 빌드 과정에서 환경 변수를 사용하여 빌드 | ||
env: | ||
REACT_APP_GATEWAY_URL: ${{ secrets.REACT_APP_GATEWAY_URL }} | ||
REACT_APP_PROMOTION_URL: ${{ secrets.REACT_APP_PROMOTION_URL }} | ||
|
||
# 5. Create SSH key file from GitHub Secrets (Private key) | ||
- name: Create SSH key file | ||
run: | | ||
echo "${{ secrets.SERVER_SSH_KEY }}" > id_rsa | ||
chmod 600 id_rsa | ||
# 6. Transfer build files to EC2 via SCP | ||
- name: Transfer build files to EC2 | ||
run: | | ||
scp -o StrictHostKeyChecking=no -i id_rsa -r ./build/* ubuntu@${{ secrets.SERVER_HOST }}:/home/ubuntu/STUDIO-EYE-WEB-PROMOTION/build/ | ||
# 7. Clean up SSH key file (for security purposes) | ||
- name: Clean up SSH key | ||
run: rm id_rsa # SSH 키를 삭제하여 보안 유지 | ||
|
||
# 8. Execute commands on EC2 to update the code and restart NGINX | ||
- name: Execute deploy script on EC2 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.SERVER_SSH_KEY }} # GitHub Secrets에서 비공개 키 사용 | ||
port: 22 | ||
script: | | ||
cd ~/STUDIO-EYE-WEB-PROMOTION | ||
sudo chmod -R 755 ./build # 권한 설정 | ||
sudo systemctl restart nginx # NGINX 재시작 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
/coverage | ||
|
||
# # production | ||
# /build | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.