自动更新 GitHub Profile README 中的 IT 邦帮忙文章

最近刚好在做自己github的profile readme
刚好想到可以抓取之前写的it邦帮忙铁人赛文章放进readme
看到github action marketplace好像没有
就自己写了一个github action 放到marketplace上
Github Action MarketPlace: https://github.com/marketplace/actions/ithome-article-post-action
专案连结: https://github.com/Charonyuu/ithome_blog_upload

如何使用

到想要使用的专案 repository将以下内容放入你想要使用的 readme 中,github action 会将 blog post 自动更新到这个位置中间。
<!-- ITHOME-POST-LIST:START --><!-- ITHOME-POST-LIST:END -->
新增.github 资料夹,再新增workflows资料夹,如果之前没有建立过,就要先建立。在 workflows 资料夹中新增档案ithome-post-update.yml:
name: Latest ithome blog update workflowon:  schedule:    # 自动更新时间    - cron: "0 * * * *" # 每小时更新(可以自动更新)  workflow_dispatch: # 手动更新permissions:  contents: write # 读写权限jobs:  update-readme-with-blog:    name: Update this repo's README with latest blog posts    runs-on: ubuntu-latest    steps:      - name: Checkout        uses: actions/checkout@v4      - name: Ithome Article Post Action        uses: Charonyuu/ithome_blog_upload@master        with:          ghToken: ${{ secrets.GITHUB_TOKEN }}          userId: "20162289"          like: "false"          comment: "false"
替换掉 userId 变成自己 ithome 的 id.範例如下
查询it帮帮忙id图片到专案 repository settings, 点选左侧的 Actions > General. 更新 "Workflow permissions"变成 "Read and write permissions"然后储存
workflow pemission图片

7.结果演示:
http://img2.58codes.com/2024/20162289OsGRuqYtvS.png

有一些参数可以调整,例如:要不要显示留言或文章撷取数量或者修改action的commiter

Workflow 选项预设值说明必填userId""你的 it 帮帮忙 idyesgh_token${{ secrets.GITHUB_TOKEN }}你的 GitHub token,用来更新 readmeyeslimit5设定要抓几个 postyesliketrue是否要显示喜欢数nocommenttrue是否要显示留言数noviewtrue是否要显示阅读数nocommit_messageUpdated with the latest ithome blog posts自动更新时 commit messagenocommitter_usernameithome-blog-upload-readme-bot自动更新时 committer usernamenocommitter_emailithome-blog-upload-readme-bot@example.com自动更新时 committer emailnoicon_emojifalse是否要用 emoji 图示显示观看喜欢与评论数

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章