-
Notifications
You must be signed in to change notification settings - Fork 2
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 #55 from Pironeer-APP/cdChan
[cd] 자동 배포 초안및 테스트 최종2
- Loading branch information
Showing
1 changed file
with
12 additions
and
21 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 |
---|---|---|
|
@@ -27,25 +27,16 @@ jobs: | |
- name: Install dependencies | ||
run: npm install | ||
|
||
# GitHub Secrets에서 SSH 키를 파일로 저장하고, 올바른 권한을 설정합니다. | ||
- name: Add SSH key | ||
run: | | ||
echo "$DEPLOY_KEY" > /tmp/deploy_key.pem | ||
chmod 600 /tmp/deploy_key.pem | ||
env: | ||
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | ||
|
||
# AWS EC2 인스턴스에 접속하여 애플리케이션을 배포합니다. | ||
- name: Deploy to AWS EC2 | ||
run: | | ||
ssh -i /tmp/deploy_key.pem -o StrictHostKeyChecking=no [email protected] | ||
cd Pironeer_Attend_Web/ | ||
pm2 stop app.js || true | ||
git pull origin main | ||
npm install --production | ||
pm2 start app.js | ||
EOF | ||
# 배포 후, SSH 키 파일을 명시적으로 삭제합니다. | ||
- name: Clean up | ||
run: rm /tmp/deploy_key.pem | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_IP }} | ||
username: ubuntu | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
script: | | ||
cd Pironeer_Attend_Web/ | ||
pm2 stop app.js || true | ||
git pull origin main | ||
npm install --production | ||
pm2 start app.js | ||