最近刚好在做自己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.範例如下到专案 repository settings, 点选左侧的 Actions > General. 更新 "Workflow permissions"变成 "Read and write permissions"然后储存
7.结果演示:
有一些参数可以调整,例如:要不要显示留言或文章撷取数量或者修改action的commiter
userId
""
你的 it 帮帮忙 idyesgh_token
${{ secrets.GITHUB_TOKEN }}
你的 GitHub token,用来更新 readmeyeslimit
5
设定要抓几个 postyeslike
true
是否要显示喜欢数nocomment
true
是否要显示留言数noview
true
是否要显示阅读数nocommit_message
Updated with the latest ithome blog posts
自动更新时 commit messagenocommitter_username
ithome-blog-upload-readme-bot
自动更新时 committer usernamenocommitter_email
ithome-blog-upload-readme-bot@example.com
自动更新时 committer emailnoicon_emoji
false
是否要用 emoji 图示显示观看喜欢与评论数