update #2
This file contains hidden or 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: | ||
| build-and-deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Node.js for backend | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' # או גרסה אחרת שתואמת את הפרויקט שלך | ||
| cache: 'npm' | ||
| cache-dependency-path: '../../backend/package-lock.json' | ||
| working-directory: ../../backend # מעבר לתיקיית הבאקאנד | ||
|
Check failure on line 22 in .github/workflows/auto.yaml
|
||
| - name: Install backend dependencies | ||
| run: npm install | ||
| working-directory: ../../backend | ||
| - name: Build backend (if needed) | ||
| run: npm run build # אם יש תהליך בנייה לבאקאנד (לדוגמה, TypeScript) | ||
| working-directory: ../../backend | ||
| - name: Set up Node.js for frontend | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' # או גרסה אחרת שתואמת את הפרויקט שלך | ||
| cache: 'npm' | ||
| cache-dependency-path: './frontend/package-lock.json' | ||
| working-directory: ../../frontend | ||
| - name: Install frontend dependencies | ||
| run: npm install | ||
| working-directory: ../../frontend | ||
| - name: Build frontend | ||
| run: npm run build | ||
| working-directory: ../../frontend | ||
| - name: Deploy to EC2 | ||
| uses: appleboy/ssh-action@master | ||
| with: | ||
| host: ${{ secrets.EC2_HOST }} | ||
| username: ${{ secrets.EC2_USER || 'ubuntu' }} | ||
| key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
| script: | | ||
| sudo rm -rf /var/www/html/* | ||
| sudo systemctl stop fullstack.service | ||
| cd /home/ubuntu/FC-cicd | ||
| git pull origin main | ||
| cd ./backend | ||
| npm install --production | ||
| cd /home/ubuntu/FC-cicd/frontend | ||
| npm install --production | ||
| npm run build | ||
| sudo cp -r /home/ubuntu/FC-cicd/frontend/build/* /var/www/html/ | ||
| sudo systemctl restart fullstack.service | ||