update 20260207

This commit is contained in:
2026-02-07 21:39:31 +08:00
parent a8105581a0
commit d215b55bc3
4 changed files with 907 additions and 1 deletions

View File

@@ -0,0 +1,76 @@
---
title: 将博客仓库转移到gitea
cover: https://pic.biss.click/image/f9767ecf-b8de-461b-8e62-8f7444297ea6.webp
categories: 技术
tags: gitea
abbrlink: d2c8521
summary: >-
这篇文章详细介绍了如何将博客仓库从现有的平台转移到Gitea。首先确保已经成功安装了Gitea。接着文章重点讲解了action文件的修改包括检查分支、缓存项目、安装Node和Hexo、安装依赖、清理文件树、生成静态文件并压缩、部署到本地仓库以及Webhook的配置。这些步骤确保了博客能够顺利迁移到Gitea并且保持了原有的功能和结构。需要注意的是文章中的action文件包含了一些具体的指令和变量如ref:
master、cache-node-modules等这些在实际操作时需要替换为具体的值。此外文章还提到了Webhook的配置这是一个可选但推荐的自定义事件触发器用于在特定事件发生时自动触发部署流程。
date: 2026-02-07 12:30:39
series:
---
在上一篇文章中已经完成了gitea的安装
那么博客源码迁移倒是没问题,直接```git remote add origin```就行但是action文件就有些变更。
这是我修改的action文件
```yaml
name: 自动部署
on:
push:
branches:
- master
release:
types:
- published
workflow_dispatch:
env:
TZ: Asia/Shanghai
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 检查分支
uses: actions/checkout@v4
with:
ref: master
- name: 缓存项目 npm 包
id: cache-node-modules
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: |
npm install
- name: 清理文件树
run: |
npm run clean
- name: 生成静态文件并压缩
run: |
npm run build
- name: 部署
run: |
cd ./public
git init
git config user.name "${{ gitea.actor }}"
git config user.email "${{ gitea.actor }}@noreply.gitea.io"
git add .
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/biss/blog.git" master:page
- name: Deploy to Server
run: |
curl -k -X POST
```
仅供参考吧最后面是webhook可以自己改改。