using Github GraphQL API to fetch issues of the specified repository on github.
use Github GraphQL API to fetch issues of the specified repository on github.
I'm using these scripts to fetch issues then generate static website(by using Hugo). see blog-hugo/generate_and_deploy.py
written in Python3, and depends on these modules:
- requests
- eventlet
install the dependencies
to use this script, you also need a
token
to access the GraphQL API, please take a look at Authenticating with GraphQL.
usage:
$ git clone https://github.com/jrdeng/github-issue-fetcher.git
# or use as submodule
# import to your project
import sys
sys.path.append('github-issue-fetcher')
import fetcher
issue_list = fetcher.fetch_issues(token, owner, repo)
the owner
and repo
specified whose/which repository you want.
you will get a list of object Issue
which defined in gql/issue.py.
mostly, you'll need to modify the query_str
in gql/gql.py to fetch the data you want. and modify the class Issue to parse the result.
for convenience, there's a sample()
in fetcher.py
.
-------------------------
fetch issues from a github repo and generate hugo site, then push the hugo site back to that github repo (as a github page)
blog hugo (deprecated, replacement: i2site)
fetch issues from github (using github-issue-fetcher),
and generate static website (using hugo).
- write blog anywhere - just open the github issue in a browser. (open, free, geek...)
- comments of blog posts are also in the issues (using utterances)
- powered by hugo
take my blog as a sample. (switched to i2site which using github actions)
- create your github page repo
- get a
token
to access the GraphQL API to fetch the issues, please take a look at Authenticating with GraphQL - clone this repo (with all submodules), and install dependent Python3 modules and hugo
- modify
config.toml
and themes as you want - run
generate_and_deploy.py
$ ./generate_and_deploy.py OPTIONS
OPTIONS:
-t|--token github token for GraphQL
-o|--owner repo owner(login)
-r|--repo repo name(without .git suffix) to fetch issue and push the site
-g|--gen path to the blog generator(hugo)
-l|--local generate and deploy site without pulling new issues(useing local MD, -t will be ignored)
-d|--dry dry run, just generate site, but do not deploy it
.
from https://github.com/jrdeng/blog-hugo
-----------------------------------------------
A hugo site uses github issues as input, and blog posts are generated
by using github actions.
A hugo site uses github issues as input, and generated by using github actions.
github issues
--> issues.json
--> hugo
--> Github Pages
example: https://jrdeng.github.io/i2site/
- clone or copy this repo as
you/you.github.io
- set the
master/docs
as the source of GitHub Pages in your repo - modify the hugo-template as you need (
config.toml
,theme
etc.) - push your changes to github.
- install utterances for comments in site.
that's almost all.
master/docs
will be generated automatically by the Github Actions while:
- push
- issues changed
for more customization, feel free to modify the hugo-issue2post.py
and the .github/workflows/main.yml
.
for example, you may want to filter the issues by author,
so only issues created by the author will be queried and generated to
the site.
you can set author
in action:
- name: Query issues by using query-issues-action
uses: jrdeng/query-issues-action@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ${{ github.repository }}
author: ${{ github.repository_owner }}
output_json: ./issues.json
from https://github.com/jrdeng/i2site
----------------------------------------
I'm using `jrdeng/i2site`
wuming.me
A hugo site uses github issues as input, and generated by using github actions.
github issues
--> issues.json
--> hugo
--> Github Pages
see also: https://github.com/jrdeng/i2site
from https://github.com/jrdeng/jrdeng.github.io
----------------------------------------------------------
用github issues做记录并生成静态博客
github-issue-fetcher
+ blog-hugo
+ cron job 的方式已经放弃,改用 Github Actions来自动发布了。具体见 #11
本文仅供参考
构思:
- 在github上写issue
- 把issue爬下来(github-issue-fetcher)
- 评论系统用https://utteranc.es/,可以跟issue完美结合
- 用hugo等生成静态博客,并发布到github page(blog-hugo)
1. 在github上写issue
正如本篇一样,写到github的issue页面里,并保持OPEN状态。
可以加一些 Labels(blog-hugo会当作tag写入博客)
2. 把issue爬下来
写了些Python脚本,通过Github GraphQL API去爬issue list。
由于API的限制,每次抓issues 最大只能100条(first:100),如果issue数目超过100, 需要用到 cursor 多次获取。
然后偶然发现author字段有时候会返回None, 有点没搞明白。。。
3. 评论系统
一句话:https://utteranc.es/ is amazing!!!
4. 用hugo等生成静态博客,并发布到github page
按照hugo和主题的需求,写Markdown文件头,以及内容。(以及评论系统的脚本)
我本地会有一个cron job自动去重新抓取issue和生成博客(如果内容没有变化,则不用push到github.
from https://github.com/jrdeng/jrdeng.github.io/issues/1
No comments:
Post a Comment