updaete main.yml
This commit is contained in:
@@ -4,10 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
# Gitea 支持 release 触发,但确保你的 Gitea 版本较新
|
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- published
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@@ -15,45 +11,52 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
# 这里的 ubuntu-latest 对应你 runner config 里定义的 label
|
runs-on: ubuntu-latest # 请确保你的 runner config.yaml 中定义了此标签
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
steps:
|
||||||
- name: 检查分支
|
- name: 检查分支
|
||||||
uses: actions/checkout@v4 # 建议先用 v4,兼容性最稳
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
# Gitea 中默认不需要专门传 token 即可 checkout 公开仓库
|
fetch-depth: 1 # 2H2G 环境下减少拉取深度,加速构建
|
||||||
# 但为了 push 回去,我们保持 fetch-depth
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: 缓存项目 npm 包
|
- name: 缓存项目 npm 包
|
||||||
id: cache-node-modules
|
id: cache-node-modules
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: node_modules
|
path: node_modules
|
||||||
key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }}
|
# 基于 package-lock.json 生成 key
|
||||||
|
key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}
|
||||||
|
|
||||||
- name: 安装 Node
|
- name: 安装 Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: "22"
|
||||||
|
|
||||||
- name: 安装依赖并生成
|
- name: 安装依赖与构建
|
||||||
run: |
|
run: |
|
||||||
|
|
||||||
npm install -g hexo-cli
|
npm install -g hexo-cli
|
||||||
npm install
|
npm install
|
||||||
npm run clean
|
npm run clean
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
- name: 部署到 Gitea Page 分支
|
- name: 部署到 Gitea Page 分支
|
||||||
# 如果你还要把编译后的网页 push 回 Gitea 的另一个分支
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
run: |
|
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
|
cd ./public
|
||||||
git init
|
git init
|
||||||
git config user.name "${{ github.actor }}"
|
git config user.name "${{ github.actor }}"
|
||||||
git config user.email "${{ github.actor }}@noreply.gitea.com"
|
git config user.email "${{ github.actor }}@noreply.gitea.com"
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Deploy: ${{ github.event.head_commit.message }} [$(date +'%Y-%m-%d %H:%M:%S')]"
|
git commit -m "Deploy: ${{ github.event.head_commit.message }} [$(date +'%Y-%m-%d %H:%M:%S')]"
|
||||||
git push --force --quiet "http://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@git.biss.click/${{ github.repository }}.git" master:page
|
|
||||||
|
git push --force "git@git.biss.click:biss/blog.git" master:page
|
||||||
|
|
||||||
- name: 通知服务器 Hook
|
- name: 通知服务器 Hook
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user