通过issues
来写博客文章,并自动部署到gh-page
。
介绍
- acyort 引擎核心,用来管理插件、工作流以及
html
输出等。 - acyort-donob-plugins:是
acyort
的插件,用来拉取issues
数据并进行处理,处理完后将对应模板进行渲染。
整体步骤
- 在github新建一个 repo
- 写入配置文件
- 添加 github token, 权限为
repo::public_repo
- 在 circleCi 加入对应的
repo
并创建 circleci token(需要保存下来) - 在
circleci
中对应项目加入variable
. - 在
repo
中添加webhook
- 写
issues
关于 gh-pages
gh-pages
有两种形式, 具体请看官方说明:
-
以
username.github.io
命名的项目,是分配给每个用户的user page
。 -
另一种是
prject page
, 各项目中通过gh-pages
分支或者通过docs
文件夹所生成的gh-pages
。
无论、以何种方式来建立起gh-pages
都可以。
但是如果以username.github.io
来创建的话,内容只能放在master
分支,并不能像其他repo
一样通过gh-pages
或者docs
文件夹生成。
下面统一用username.github.io
来创建gh-pages
详细步骤
创建repo
- 创建一个
username.github.io
的repo
,负责接收生成后的html
内容, 并生成user page
。 - 创建一个
blog-config
(名字随意),用来管理blog
配置,以及issues
管理。
申请两个 token
两个token
都要自行保存, 关闭就找不回来。
-
github token
申请一个具有写权限的github token,
scope
选择repo::public_repo
, 用于将生成后的文件通过api
直接push
到该项目中。 -
circleci token
申请一个circleci token, 用来通过
webhook
来触发circle build
。
写入配置文件
在blog-config
中,创建以下文件:
|-.circleci
|- config.yml // circleCi 的配置文件
|-config.yml // acyort 配置文件
|-package.json // 这个不用说
package.json {
"name": "blog name",
"version": "1.0.0",
"description": "blog",
"main": "index.js",
"scripts": {
"deploy": "acyort flow"
},
"dependencies": {
"acyort": "^3.1.1",
"acyort-donob-renderer": "^1.5.0",
"acyort-plugin-fetch-issues": "^1.3.1",
"acyort-plugin-rss": "^1.5.0",
"acyort-templates-donob-plus": "^1.5.1",
"gh-pages": "^2.0.1"
}
} config.yml(acyort 配置文件) title: blog name # 博客名称
description: blog desc # 博客简介
url: http://username.github.io # 博客url
template: acyort-templates-donob-plus
menu:
Archives: /archives/
Tags: /tags/
repository: username/blog-config # 写 issues 的项目
public: public
timezone: Asia/Shanghai
plugins:
- acyort-plugin-fetch-issues
- acyort-donob-renderer .circleci/config.yml # 注意这个文件名为 config.yml,在 .circleci 目录下
version: 2
jobs:
build:
docker:
- image: node:latest
working_directory: ~/acyort
branches:
only:
- master
steps:
- checkout
- restore_cache:
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run: yarn install
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run: yarn deploy
- run: git config user.name "" # 你的 github username
- run: git config user.email "" # 你的 github email
- run: npx gh-pages -d public -r https://${gh_token}@github.com/username/username.github.io.git -b master -m "Updated by circleci - `date`" # ${gh_token}, 这个token就是具有写权限的github token, 会在 circleci 配置。 配置circleci
配置webhook回到
写issues至此博客已经算搭建完成,只需要在 最后更多配置请参考 from https://github.com/zWingz/my-blog-config/issues/29 (https://zwing.site/posts/417715171.html) demo site: https://zwing.site |
No comments:
Post a Comment