777 字
4 分钟
国内静态博客一键部署

前言#

手动部署以及博客配置参考国内自动化静态博客搭建

准备#

AtomGit#

AtomGit是国内由开放原子基金会运营的Git托管平台,它支持Pages服务,并且具有良好的访问速度。

  1. 一个账号与一个空仓库

你需要先在AtomGit上注册一个账号,并创建一个空仓库,用于部署静态博客的站点构建文件。

  1. Pages服务申请

该仓库需要开启Pages服务。参考AtomGit Pages

开启Pages服务后,AtomGit会自动为你的仓库分配一个uri,例如https://<username>.atomgit.net/<repo-name>。你可以通过这个url来访问你的静态博客。

  1. 访问令牌

你需要创建一个访问令牌(Personal Access TokenPAT),用于Github Action访问你的仓库。点击此处生成

注意: 访问令牌需要勾选repo权限,否则Github Action无法访问你的仓库。

Github#

  1. 一个账号 你需要一个Github账号,并且需要创建一个仓库,用于存放静态博客的源文件。这个仓库不需要开启Pages服务。从该仓库中,你可以通过Github Action来生成静态博客的站点文件,并将其部署到AtomGit上。

Github Action 部署#

1. Fork 7emotions/Fuwari#

首先,你需要Fork 我的Fuwari 到你的Github账号下。

2. 配置Secret#

在Fork后的仓库中,点击Settings,然后点击Secrets and variables,选择Actions,点击New repository secret,添加以下三个Secret

  • TOKEN:AtomGit的访问令牌(PAT),用于Github Action访问你的AtomGit仓库。
  • USER:AtomGit的用户名,用于Github Action访问你的AtomGit仓库。
  • REPO:AtomGit的仓库名,用于Github Action访问你的AtomGit仓库。

例如,我的AtomGit仓库的uri为https://atomgit.com/<username>/<repo-name>,那么USER<username>REPO<repo-name>

3. 启用Actions#

Github仓库中,点击Actions,选择Deploy Pages,点击Run workflow,选择分支为main,点击Run workflow

alt text

刷新页面,可以看到Github Action正在运行。

alt text

约莫1分钟后,出现如下提示,说明Github Action运行完成。

alt text

Github Action运行完成后,你可以访问https://<username>.atomgit.net/<repo-name>查看你的静态博客。

例如,我的AtomGit仓库的uri为https://atomgit.com/7emotions/blog,那么我的静态博客的访问地址为https://7emotions.atomgit.net/blog

Docker 部署#

1. Fork 7emotions/Fuwari#

首先,你需要Fork 我的Fuwari 到你的Github账号下。

2. Clone 仓库#

在本地,使用git clone命令克隆你的Fork仓库。

git clone https://github.com/<username>/fuwari.git

3. 配置环境变量#

fuwari目录下,创建一个.env文件,并添加以下内容。

TOKEN=<AtomGit-Token>
USER=<username>
REPO=<repo-name>
GIT_DOMAIN=atomgit.com
BRANCH=pages

文中<AtomGit-Token><username><repo-name>分别代表AtomGit的访问令牌(PAT)、AtomGit的用户名、AtomGit的仓库名。

4. 构建与运行#

fuwari目录下,使用以下命令构建与运行。

docker-compose up -d

5. 访问博客#

Docker容器运行完成后,你可以访问https://<username>.atomgit.net/<repo-name>查看你的静态博客。

博文发布#

无论是Github Action部署还是Docker部署,每次向远端推送博文,会自动触发Github Action,生成静态博客的站点文件,并将其部署到AtomGit上。

国内静态博客一键部署
https://lorenzofeng.top/posts/onetap/
作者
Lorenzo Feng
发布于
2025-03-14
许可协议
CC BY-NC-SA 4.0