update
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
name: 自动部署
|
name: 自动部署
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
env:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -13,39 +16,41 @@ jobs:
|
|||||||
- name: 检查分支
|
- name: 检查分支
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
ref: master
|
||||||
persist-credentials: false # 必须为 false,防止 1.25.4 的默认 Token 干扰 SSH
|
- name: 缓存项目 npm 包
|
||||||
|
id: cache-node-modules
|
||||||
- name: 安装依赖与构建
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-nodeModules-
|
||||||
|
- name: 安装 Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "22.x"
|
||||||
|
- name: 安装 Hexo
|
||||||
|
run: |
|
||||||
|
npm install hexo-cli --global
|
||||||
|
- name: 安装依赖
|
||||||
|
if: steps.cache-node-modules.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
npm install -g hexo-cli
|
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
- name: 清理文件树
|
||||||
|
run: |
|
||||||
- name: 部署 (内存优化版)
|
npm run clean
|
||||||
env:
|
- name: 生成静态文件并压缩
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
run: |
|
||||||
|
npm run build
|
||||||
|
- name: 部署
|
||||||
run: |
|
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
|
cd ./public
|
||||||
git init
|
git init
|
||||||
git config user.name "biss"
|
git config user.name "${{ gitea.actor }}"
|
||||||
git config user.email "biss@noreply.gitea.com"
|
git config user.email "${{ gitea.actor }}@noreply.gitea.io"
|
||||||
|
|
||||||
# 3. 针对 2H2G 的内存优化:限制 Git 的打包内存占用
|
|
||||||
git config --global pack.windowMemory "16m"
|
|
||||||
git config --global pack.packSizeLimit "20m"
|
|
||||||
git config --global core.packedGitLimit "32m"
|
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Deploy: $(date)"
|
git commit -m "${{ gitea.event.head_commit.message }}··[$(date +"%Z %Y-%m-%d %A %H:%M:%S")]"
|
||||||
|
git push --force --quiet "https://${{ gitea.actor }}:${{ secrets.DEPLOY_TOKEN }}@git.biss.click/${{ gitea.repository }}.git" master:page
|
||||||
# 4. 执行推送 (去掉 -v 防止日志过大导致内存波动)
|
- name: Deploy to Server
|
||||||
# 注意:如果端口不是 22,请确保地址包含端口号
|
run: |
|
||||||
git push --force "git@git.biss.click:biss/blog.git" master:page 2>&1
|
curl -k -X POST "https://45.145.229.95:40606/hook?access_key=1XJG8IvYTSZVvD5dpm86GYIpQxgxBcucULnX1MFskZSKayXU"
|
||||||
Reference in New Issue
Block a user