Skip to content

update github workflow to build the project before deploying #8

update github workflow to build the project before deploying

update github workflow to build the project before deploying #8

Workflow file for this run

name: πŸš€ Deploy website on push
on:
push:
branches:
- main
jobs:
web-deploy:
name: πŸŽ‰ Deploy
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
# Step 1: Install and Build Project Locally
- name: πŸ”¨ Build Project Locally
run: |
npm install
npm run build
# Step 2: Deploy Files to the Server
- name: πŸ“‚ Sync files to server
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: ${{ vars.FTP_SERVER }}
username: ${{ vars.FTP_USERNAME }}
password: ${{ vars.FTP_PASSWORD }}
local-dir: ./ # Sync all files in the root directory (after build)
server-dir: /home/tbtouris/api/ # Your server directory
exclude: |
**/.git*
**/.git*/**
**/node_modules/**
**/frontend/node_modules/**
**/backend/node_modules/**
# Step 3: Run npm install on the server after deployment
- name: πŸ”§ Run npm install on server
run: |
sshpass -p "${{ vars.SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no -T -p ${{ vars.SSH_PORT }} ${{ vars.SSH_USER }}@${{ vars.SSH_HOST }} << 'EOF'
cd /home/tbtouris/api
npm install
EOF
env:
SSH_PASSWORD: ${{ vars.SSH_PASSWORD }}
SSH_USER: ${{ vars.SSH_USER }}
SSH_HOST: ${{ vars.SSH_HOST }}
SSH_PORT: ${{ vars.SSH_PORT }}