在上一篇文章中已经完成了gitea的安装
那么博客源码迁移倒是没问题,直接git remote add origin就行,但是action文件就有些变更。
这是我修改的action文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| 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,可以自己改改。