gitea: add workflow for CI/CD
This commit is contained in:
49
.gitea/workflows/main.yml
Normal file
49
.gitea/workflows/main.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
name: 自动部署
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
# Gitea 支持 release 触发,但确保你的 Gitea 版本较新
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
TZ: Asia/Shanghai
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
# 这里的 ubuntu-latest 对应你 runner config 里定义的 label
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 检查分支
|
||||
uses: actions/checkout@v4 # 建议先用 v4,兼容性最稳
|
||||
with:
|
||||
# Gitea 中默认不需要专门传 token 即可 checkout 公开仓库
|
||||
# 但为了 push 回去,我们保持 fetch-depth
|
||||
fetch-depth: 0
|
||||
|
||||
- name: 缓存项目 npm 包
|
||||
id: cache-node-modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }}
|
||||
|
||||
- name: 安装 Node
|
||||
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: 通知服务器 Hook
|
||||
run: |
|
||||
curl -k -X POST "https://45.145.229.95:40606/hook?access_key=1XJG8IvYTSZVvD5dpm86GYIpQxgxBcucULnX1MFskZSKayXU"
|
||||
Reference in New Issue
Block a user