fix hotkey issue #1204
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy《LeetCode-Cookbook》 | |
| on: | |
| push: | |
| branches: | |
| - master # 只在master上push触发部署 | |
| - add_hugo | |
| paths-ignore: # 下列文件的变更不触发部署,可以自行添加 | |
| - README.md | |
| - LICENSE | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest # 使用ubuntu系统镜像运行自动化脚本 | |
| steps: # 自动化步骤 | |
| - uses: actions/checkout@v5 # 第一步,下载代码仓库 | |
| with: | |
| fetch-depth: 0 # config.toml 里 enableGitInfo = true,需要完整 git 历史,否则取不到每页“最后修改”信息 | |
| - name: Setup Hugo # 第二步,安装 hugo | |
| uses: peaceiris/actions-hugo@v3 | |
| with: | |
| hugo-version: '0.74.3' | |
| extended: true # 关键修复:主题用 resources.ToCSS 编译 book.scss,必须用 extended 版,否则 build 直接报错 | |
| - name: Build # 第三步,编译 hugo | |
| run: | | |
| cd ./website | |
| hugo -D --minify | |
| - name: Deploy to Server # 第四步:在 runner 上用 rsync 把构建产物推到服务器 | |
| # 关键修复:之前用 appleboy/ssh-action,它会把 script 放到“服务器上”执行, | |
| # 于是 rsync 在服务器本机找不到 ./website/public/,还要再 SSH 回自己 → Permission denied。 | |
| # 正确做法是直接在 runner 上跑 rsync,用 DEPLOY_KEY 推到服务器。 | |
| env: | |
| DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | |
| SSH_HOST: ${{ secrets.SSH_HOST }} | |
| SSH_USERNAME: ${{ secrets.SSH_USERNAME }} | |
| SERVER_PORT: ${{ secrets.SERVER_PORT }} | |
| SERVER_DESTINATION: ${{ secrets.SERVER_DESTINATION }} | |
| run: | | |
| mkdir -p ~/.ssh | |
| printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key | |
| chmod 600 ~/.ssh/deploy_key | |
| # 服务器较旧(OpenSSH 5.x),只认旧的 ssh-rsa(SHA-1) 签名, | |
| # 而新版 OpenSSH 默认禁用了它,所以要显式加回 PubkeyAcceptedAlgorithms=+ssh-rsa, | |
| # 否则会报 "sign_and_send_pubkey: no mutual signature supported"。 | |
| rsync -avz --delete --exclude='*.pyc' \ | |
| -e "ssh -i ~/.ssh/deploy_key -p ${SERVER_PORT:-22} -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o PubkeyAcceptedAlgorithms=+ssh-rsa" \ | |
| ./website/public/ \ | |
| "${SSH_USERNAME}@${SSH_HOST}:${SERVER_DESTINATION:-/var/www/books/leetcode/}" |