diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 63f9b91..d9bdbad 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -17,15 +17,22 @@ jobs: - name: Generate HTML run: pandoc index.md -s -o index.html --css styles.css - - name: Deploy to server via SSH - uses: appleboy/ssh-action@v1.2.0 - with: - host: ${{ secrets.SSH_HOST }} - username: ${{ secrets.SSH_USER }} - key: ${{ secrets.SSH_KEY }} - port: ${{ secrets.SSH_PORT || '22' }} - script: | - git clone https://tea.ahmza.com/ahmza/ahmza-dad.git /home/${{ secrets.SSH_USER }}/repo - cp /home/${{ secrets.SSH_USER }}/repo/index.html /usr/share/nginx/html/ - cp /home/${{ secrets.SSH_USER }}/repo/styles.css /usr/share/nginx/html/ - nginx -s reload + - name: Setup SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + + - name: Deploy to server via rsync + run: | + rsync -avz --delete \ + -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \ + --exclude='.git' \ + index.html styles.css nginx.conf \ + ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/usr/share/nginx/html/ + + - name: Reload nginx + run: | + ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \ + "nginx -s reload"