抓取个人博客文章目录到github主页

2024-11-11-194849
如图所见,我在我的github主页上加了我的最近的个人博客的文章

所用项目

gautamkrishnar/blog-post-workflow: Show your latest blog posts from any sources or StackOverflow activity or Youtube Videos on your GitHub profile/project readme automatically using the RSS feed

创建blog-post-workflow.yml

具体的路径应该是.github/workflows/blog-post-workfliw.yml

复制粘贴

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
# This is a basic workflow to help you get started with Actions

name: Latest blog post workflow

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
schedule: # Run workflow automatically
- cron: '0 3 * * *' # Runs at 3:00 # 定时任务,每天3:00触发

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
update-readme-with-blog:
name: Update README with latest blog posts
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Update posts
uses: gautamkrishnar/blog-post-workflow@master
with:
feed_list: "https://xingwangzhe.fun/atom.xml" #这里应该替换成自己的rss地址
max_post_count: 7 # 顾名思义,最大文章数。

添加关键词

在你的主页的readme里面添加

1
2
<!-- BLOG-POST-LIST:START -->
<!-- BLOG-POST-LIST:END -->

给予编辑权限

在你主页仓库的settings里,打开Actions设置,选择general,然后选中第一个。并点击save保存设置。
2024-11-11-200456

触发流程

然后在Actions选择触发Run workflow
2024-11-11-200147

然后静待结束,就大功告成了!

当然这个还有更多的参数使用,不过我懒得弄:),怎么方便怎么来吧:)

参考

利用GitHub Actions自动获取博客rss文章 | 二丫讲梵
gautamkrishnar/blog-post-workflow: Show your latest blog posts from any sources or StackOverflow activity or Youtube Videos on your GitHub profile/project readme automatically using the RSS feed