name: Deploy Hugo site on: push: branches: - master # 或者您的主分支名称 jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Setup Hugo uses: peaceiris/actions-hugo@v2 with: hugo-version: 'latest' - name: Build Hugo site run: hugo --minify - name: Deploy to server uses: appleboy/ssh-action@master with: host: ${{ secrets.SERVER_HOST }} username: ${{ secrets.SERVER_USER }} key: ${{ secrets.SERVER_SSH_KEY }} script: | cd /usr/share/nginx/hugo-demo git pull origin main hugo --minify # 如果需要,可以添加额外的部署步骤,比如重启web服务器等