1 line
2.9 KiB
JSON
1 line
2.9 KiB
JSON
{"title":"将博客仓库转移到gitea","slug":"d2c8521","url":"https://blog.biss.click/posts/d2c8521/","date":"2026-02-07T12:30:39.000Z","updated":null,"summary":"这篇文章详细介绍了如何将博客仓库从现有的平台转移到Gitea。首先,确保已经成功安装了Gitea。接着,文章重点讲解了action文件的修改,包括检查分支、缓存项目、安装Node和Hexo、安装依赖、清理文件树、生成静态文件并压缩、部署到本地仓库以及Webhook的配置。这些步骤确保了博客能够顺利迁移到Gitea,并且保持了原有的功能和结构。需要注意的是,文章中的action文件包含了一些具体的指令和变量,如ref: master、cache-node-modules等,这些在实际操作时需要替换为具体的值。此外,文章还提到了Webhook的配置,这是一个可选但推荐的自定义事件触发器,用于在特定事件发生时自动触发部署流程。","tags":["gitea"],"categories":["技术"],"series":null,"seriesOrder":null,"contentFormat":"text/markdown","content":"在上一篇文章中已经完成了gitea的安装\n那么博客源码迁移倒是没问题,直接```git remote add origin```就行,但是action文件就有些变更。\n这是我修改的action文件:\n\n```yaml\nname: 自动部署\non:\n push:\n branches:\n - master\n release:\n types:\n - published\n workflow_dispatch:\nenv:\n TZ: Asia/Shanghai\njobs:\n deploy:\n runs-on: ubuntu-latest\n steps:\n - name: 检查分支\n uses: actions/checkout@v4\n with:\n ref: master\n - name: 缓存项目 npm 包\n id: cache-node-modules\n uses: actions/cache@v3\n with:\n path: node_modules\n key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }}\n restore-keys: |\n ${{ runner.os }}-nodeModules-\n - name: 安装 Node\n uses: actions/setup-node@v4\n with:\n node-version: \"22.x\"\n - name: 安装 Hexo\n run: |\n npm install hexo-cli --global\n - name: 安装依赖\n if: steps.cache-node-modules.outputs.cache-hit != 'true'\n run: |\n npm install\n - name: 清理文件树\n run: |\n npm run clean\n - name: 生成静态文件并压缩\n run: |\n npm run build\n - name: 部署\n run: |\n cd ./public\n git init\n git config user.name \"${{ gitea.actor }}\"\n git config user.email \"${{ gitea.actor }}@noreply.gitea.io\"\n git add .\n git commit -m \"${{ gitea.event.head_commit.message }}··[$(date +\"%Z %Y-%m-%d %A %H:%M:%S\")]\"\n git push --force --quiet \"https://${{ gitea.actor }}:${{ secrets.DEPLOY_TOKEN }}@git.biss.click/biss/blog.git\" master:page\n - name: Deploy to Server\n run: |\n curl -k -X POST \n```\n仅供参考吧,最后面是webhook,可以自己改改。"} |