update next config for images domain #11
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' | |
set -e # Exit on any error | |
sudo -i | |
# Remove old dependencies and build artifacts (clean slate) | |
rm -rf node_modules package-lock.json .next | |
# Navigate to the project directory | |
cd /var/www/allo-experts-frontend | |
# Pull the latest changes from the main branch | |
git reset --hard # Discard local changes | |
git pull origin main | |
# Set permissions in case any files are root-owned | |
# sudo chown -R ubuntu:ubuntu . | |
# Install dependencies | |
npm install | |
# Build the project | |
npm run build | |
# Start or restart the application using PM2 | |
pm2 start npm --name "allo-experts-frontend" -- run start || pm2 restart "allo-experts-frontend" | |
# Save the PM2 process list | |
pm2 save | |
EOF |