58 lines
1.6 KiB
YAML
58 lines
1.6 KiB
YAML
name: 自动部署
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
TZ: Asia/Shanghai
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 检查分支
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- 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:
|
|
node-version: "22"
|
|
|
|
- name: 安装依赖与构建
|
|
run: |
|
|
npm install -g hexo-cli
|
|
npm install
|
|
npm run clean
|
|
npm run build
|
|
|
|
- name: 部署到 Gitea Page 分支
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
ssh-keyscan git.biss.click >> ~/.ssh/known_hosts
|
|
cd ./public
|
|
git init
|
|
git config user.name "${{ github.actor }}"
|
|
git config user.email "${{ github.actor }}@noreply.gitea.com"
|
|
git add .
|
|
git commit -m "Deploy: ${{ github.event.head_commit.message }} [$(date +'%Y-%m-%d %H:%M:%S')]"
|
|
git push --force "git@git.biss.click:biss/blog.git" master:page
|
|
|
|
- name: 通知服务器 Hook
|
|
run: |
|
|
curl -k -X POST "https://45.145.229.95:40606/hook?access_key=1XJG8IvYTSZVvD5dpm86GYIpQxgxBcucULnX1MFskZSKayXU" |