Files
blog/.gitea/workflows/main.yml
2026-02-07 17:37:24 +08:00

51 lines
1.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: 自动部署
on:
push:
branches:
- master
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 检查分支
uses: actions/checkout@v4
with:
fetch-depth: 1
persist-credentials: false # 必须为 false防止 1.25.4 的默认 Token 干扰 SSH
- name: 安装依赖与构建
run: |
npm install -g hexo-cli
npm install
npm run build
- name: 部署 (内存优化版)
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
# 1. 注入 SSH 密钥
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan git.biss.click >> ~/.ssh/known_hosts
# 2. 准备推送
cd ./public
git init
git config user.name "biss"
git config user.email "biss@noreply.gitea.com"
# 3. 针对 2H2G 的内存优化:限制 Git 的打包内存占用
git config --global pack.windowMemory "16m"
git config --global pack.packSizeLimit "20m"
git config --global core.packedGitLimit "32m"
git add .
git commit -m "Deploy: $(date)"
# 4. 执行推送 (去掉 -v 防止日志过大导致内存波动)
# 注意:如果端口不是 22请确保地址包含端口号
git push --force "git@git.biss.click:biss/blog.git" master:page 2>&1