Merge pull request #19 from cristinalare/feat/deploy #1
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 to EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.EC2_SSH_KEY }} | |
- name: Deploy to EC2 | |
run: | | |
ssh -o StrictHostKeyChecking=no [email protected] << 'EOF' | |
# Navigate to your project directory | |
cd /var/www/allo-experts-frontend | |
# Install dependencies | |
npm install > output.log 2>&1 | |
# Build the project | |
npm run build >> output.log 2>&1 | |
# Start or restart the application using PM2 | |
pm2 start npm --name "allo-experts-frontend" -- run start >> output.log 2>&1 || pm2 restart "allo-experts-frontend" >> output.log 2>&1 | |
# Save the PM2 process list | |
pm2 save >> output.log 2>&1 | |
EOF |