name: Deploy to Server

on:
  push:
    tags:
      - 'v*.*.*' 
  workflow_dispatch:  
jobs:
  deploy:
    runs-on: ubuntu-latest
    
    steps:
    - name: 检出代码
      uses: actions/checkout@v3
      
    - name: 部署到服务器
      uses: appleboy/ssh-action@v1
      with:
        host: ${{ secrets.SERVER_HOST }}
        username: ${{ secrets.SERVER_USERNAME }}
        key: ${{ secrets.SERVER_SSH_KEY }}
        passphrase: ${{ secrets.SSH_PASSPHRASE }}
        script: |
          docker pull ghcr.io/drizzletime/foxel:dev
          docker stop foxel-container || true
          docker rm foxel-container || true
          docker run -d --name foxel-container -p 8848:80 \
            -v /var/lib/docker/volumes/Foxel/_data:/app/Uploads \
            -e "DEFAULT_CONNECTION=${{ secrets.DEFAULT_CONNECTION }}" \
            --pull always ghcr.io/drizzletime/foxel:dev
