forked from FC-DEV-FinalProject/FinalProject_Be3C_FE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from FC-FINAL-TEAM-1/develop
devlop → main 병합
- Loading branch information
Showing
52 changed files
with
1,915 additions
and
582 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Deploy to AWS EC2 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # main 브랜치에 push할 때 실행 | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# 1. 리포지토리 체크아웃 | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# 2. Node.js 설치 및 설정 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
# 3. 프로젝트 빌드 | ||
- name: Install dependencies and build | ||
env: | ||
VITE_API_URL: ${{ secrets.VITE_API_URL }} # GitHub Secrets에서 API URL 가져오기 | ||
run: | | ||
# Vite용 .env 파일 생성 | ||
echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" > .env | ||
# 의존성 설치 및 빌드 | ||
npm ci | ||
npm run build | ||
# 4. EC2 서버로 배포 | ||
- name: Deploy to EC2 | ||
env: | ||
SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }} # EC2 접속을 위한 SSH Key | ||
USER: ${{ secrets.EC2_USER }} # EC2 사용자 이름 | ||
HOST: ${{ secrets.EC2_HOST }} # EC2 서버 호스트 | ||
PATH: ${{ secrets.EC2_PATH }} # EC2 서버의 배포 경로 | ||
run: | | ||
# SSH 키 설정 | ||
mkdir -p ~/.ssh | ||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
# 임시 디렉토리 생성 및 빌드 파일 업로드 | ||
ssh -i ~/.ssh/id_rsa $USER@$HOST "mkdir -p $PATH-temp" | ||
scp -i ~/.ssh/id_rsa -r dist/* $USER@$HOST:$PATH-temp | ||
# 기존 폴더 백업 및 교체 | ||
ssh -i ~/.ssh/id_rsa $USER@$HOST " | ||
mv $PATH $PATH-backup-$(date +%Y%m%d%H%M%S) || true && | ||
mv $PATH-temp $PATH | ||
" | ||
# 파일 권한 설정 | ||
ssh -i ~/.ssh/id_rsa $USER@$HOST "sudo chown -R www-data:www-data $PATH" | ||
# 오래된 백업 삭제 | ||
ssh -i ~/.ssh/id_rsa $USER@$HOST " | ||
find $PATH-backup-* -type d -mtime +7 -exec rm -rf {} + | ||
" |
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.