Skip to content

메인 반영

메인 반영 #1

Workflow file for this run

name: Deploy on Merge to main
on:
pull_request:
types:
- closed
branches:
- main
jobs:
deploy:
name: Deploy to EC2
if: github.event.pull_request.merged == true # PR이 머지된 경우만 실행
runs-on: ubuntu-latest
concurrency:
group: deploy
cancel-in-progress: true # 이전 실행 중인 워크플로를 취소
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H "${{ vars.EC2_HOST }}" >> ~/.ssh/known_hosts
- name: Execute Deployment Script on EC2
run: |
ssh ec2-user@${{ vars.EC2_HOST }} << 'EOF'
cd /home/ec2-user/starchive/scripts
git checkout main
# 스프링 배포 스크립트 실행
./spring-deploy.sh
# nestjs 배포 스크립트 실행
./nestjs-deploy.sh
EOF