# Simple workflow for deploying static content to GitHub Pages
name: 🚀 Deploy website on push

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["main"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  ci:
    uses: ./.github/workflows/ci.yml
    secrets: inherit
  
  web-deploy:
    name: 🎉 Deploy
    runs-on: ubuntu-latest
    steps:
    - name: 🚚 Get latest code
      uses: actions/checkout@v4

    # https://d2lang.com/tour/install/
    - name: Install D2
      run: |
        curl -fsSL https://d2lang.com/install.sh | sh -s --          

    - name: Install bun
      uses: oven-sh/setup-bun@v1
      with:
        bun-version: latest

    - name: Install dependencies
      run: |
        bun install
  
    - name: 🔨 Build Project
      run: |
        bun run build
    
    - name: 📂 Sync files
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        local-dir: dist/
        server-dir: /
        server: ${{ secrets.FTP_HOST }}
        username: ${{ secrets.FTP_USERNAME }}
        password: ${{ secrets.FTP_PASSWORD }}
