name: Deploy PROD

on:
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
    inputs:
      ref:
        type: string
        description: Deploy a specific commit by hash (optional)

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        ref: ${{ github.event.inputs.ref }}
    - name: Install Node.js
      uses: actions/setup-node@v2
      with:
        node-version: 16
        cache: 'npm'
    - run: npm install
    - run: npm run build:prod
    - name: Deploy over FTP
      uses: SamKirkland/FTP-Deploy-Action@4.2.0
      with:
        # ftp server
        server: ${{ secrets.PROD_ADDRESS }}
        port: ${{secrets.PROD_PORT }}
        # ftp username
        username: ${{ secrets.PROD_USERNAME }}
        # ftp password
        password: ${{ secrets.PROD_PASSWORD }}
        # protocol to deploy with - ftp, ftps, or ftps-legacy
        protocol: ftps
        # Folder to upload from, must end with trailing slash /
        local-dir: build/
        # Path to upload to on the server. Must end with trailing slash /
        server-dir: /
        # Prints which modifications will be made with current config options, but doesnt actually make any changes
        dry-run: false
        # Deletes ALL contents of server-dir, even items in excluded with exclude argument
        dangerous-clean-slate: true
        # An array of glob patterns, these files will not be included in the publish/delete process
        # exclude:
        # How verbose should the information be - minimal, standard, or verbose
        log-level: standard
        # strict or loose
        security: loose
