Skip to content

Merge pull request #29 from BlendRush/Imasha_dev_connector #51

Merge pull request #29 from BlendRush/Imasha_dev_connector

Merge pull request #29 from BlendRush/Imasha_dev_connector #51

Workflow file for this run

name: Deploy Frontend
on:
push:
branches:
- supuni-dev
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Build frontend
run: npm run build
- name: Check build folder exists
run: |
if [ ! -d "build" ]; then
echo "❌ build folder not found. Check if 'npm run build' works."
exit 1
fi
- name: Copy build folder to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.FRONTEND_EC2_IP }}
username: ubuntu
key: ${{ secrets.FRONTEND_EC2_SSH_KEY }}
source: "build" # ✅ Changed from dist to build
target: "/home/ubuntu/frontend"
- name: Deploy on EC2 via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.FRONTEND_EC2_IP }}
username: ubuntu
key: ${{ secrets.FRONTEND_EC2_SSH_KEY }}
timeout: 600s
command_timeout: 600s
script: |
sudo apt-get update
sudo apt-get install -y nginx
sudo rm -rf /var/www/html/*
sudo cp -r /home/ubuntu/frontend/build/* /var/www/html/ # ✅ Changed dist → build
sudo systemctl restart nginx
echo "✅ Frontend deployed successfully!"