Merge pull request #13 from wang-bam-bbang/comment #10
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
name: Deploy Find-it Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Add SSH Key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.AWS_EC2_SSH_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -H ${{ secrets.AWS_EC2_HOST }} >> ~/.ssh/known_hosts | |
- name: Deploy to EC2 | |
run: | | |
ssh -i ~/.ssh/id_rsa ec2-user@${{ secrets.AWS_EC2_HOST }} << 'EOF' | |
cd ~/find-it-be | |
git pull origin main | |
npm install | |
npx prisma generate | |
npx prisma migrate deploy | |
npm run build | |
pm2 restart all | |
EOF |