name: 🚀 Publish Website to CPanel
on:
  push:
    branches:
      - dev
jobs:
  FTP-Deploy-Action:
    name: 🎉 Deploy
    runs-on: ubuntu-latest

    steps:
      - name: 🚚 Get latest code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Use Node.js 16
        uses: actions/setup-node@v3
        with:
          node-version: "16"

      - name: Cache npm dependencies
        uses: actions/cache@v4
        id: cache-node-modules
        with:
          path: "**/node_modules"
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

      - name: 🔨 Install Dependencies
        if: steps
        run: |
          npm install
          npm run build
          composer install
          git reset --hard
      - name: 📂 Sync folders and files to the server
        uses: SamKirkland/FTP-Deploy-Action@4.3.3
        with:
          server: ${{ secrets.FTP_SERVER }}
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}
          server-dir: "/"