This commit is contained in:
2026-02-07 17:31:26 +08:00
parent 2a75f93564
commit c27e7dbc32

View File

@@ -11,23 +11,14 @@ env:
jobs:
deploy:
# 确保你的 runner config.yaml 中定义了此标签
runs-on: ubuntu-latest
steps:
- name: 检查分支
uses: actions/checkout@v4
with:
fetch-depth: 1
# 重要:在 1.25+ 版本中,禁用默认凭据以避免与 SSH 密钥冲突
persist-credentials: false
- name: 缓存项目 npm 包
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}
- name: 安装 Node.js
uses: actions/setup-node@v4
with:
@@ -37,41 +28,33 @@ jobs:
run: |
npm install -g hexo-cli
npm install
npm run clean
npm run build
- name: 强制调试部署
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
# 1. 验证私钥是否加载成功
if [ -z "$SSH_PRIVATE_KEY" ]; then
echo "错误: 仓库 Secrets 中的 SSH_PRIVATE_KEY 是空的!"
exit 1
fi
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
# 2. 详细测试 SSH 连接 (不使用 quiet强制显示结果)
ssh-keyscan -p 22 git.biss.click >> ~/.ssh/known_hosts
ssh -vT -i ~/.ssh/id_ed25519 git@git.biss.click || true
# 3. 部署并移除 --quiet打印所有 Git 原始报错
cd ./public
git init
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@noreply.gitea.com"
git add .
git commit -m "Debug Deploy: $(date)"
# 开启环境变量调试输出
export GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no"
# 推送时删除 --quiet
git push --force -v "git@git.biss.click:biss/blog.git" master:pages
- name: 通知服务器 Hook
- name: 强制调试部署 (强制输出所有信息)
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
curl -k -X POST "https://45.145.229.95:40606/hook?access_key=1XJG8IvYTSZVvD5dpm86GYIpQxgxBcucULnX1MFskZSKayXU"
# 1. 设置 SSH
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
# 2. 强制打印 SSH 握手日志,看看是哪一步断了
# 这里如果没有输出内容,说明网络解析 git.biss.click 就已经挂了
ssh-keyscan -v git.biss.click >> ~/.ssh/known_hosts 2>&1
# 3. 模拟 Git 内部的 SSH 详细连接测试
# 这一行一定会输出大量的日志,哪怕是报错
ssh -vT -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no git@git.biss.click 2>&1 || true
# 4. 准备推送
cd ./public
git init
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@noreply.gitea.com"
git add .
git commit -m "Debug Deploy"
# 5. 关键:强制 Git 输出详细过程
# 绝对不要加 --quiet
GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_ed25519" git push --force -v "git@git.biss.click:biss/blog.git" master:page 2>&1