在你的 GitHub 个人资料自述文件中自动显示你最新的 dev.to 帖子
我刚刚创建了一个 GitHub Action,它可以让您自动将来自 Dev.to 和其他来源的最新博客文章的链接添加到您的 Github Profile 自述文件中。
GitHub 上的项目:https://github.com/gautamkrishnar/blog-post-workflow
示例自述文件:https://github.com/gautamkrishnar
演示视频
如何使用
- 为这个repo加星标😉
- 转到您的存储库
- 将以下部分添加到您的README.md文件中,您可以输入任何标题。只需确保
<!-- BLOG-POST-LIST:START --><!-- BLOG-POST-LIST:END -->
在 readme 文件中使用即可。工作流程会将此评论替换为实际的博客文章列表:
# Blog posts
<!-- BLOG-POST-LIST:START -->
<!-- BLOG-POST-LIST:END -->
- 创建一个名为的文件夹,如果不存在则在其中
.github
创建一个文件夹。workflows
- 在工作流文件夹中创建一个名为
blog-post-workflow.yml
以下内容的新文件:
name: Latest blog post workflow
on:
schedule: # Run workflow automatically
- cron: '0 * * * *' # Runs every hour, on the hour
workflow_dispatch: # Run workflow manually (without waiting for the cron to be called), through the Github Actions Workflow page directly
permissions:
contents: write # To write the generated contents to the readme
jobs:
update-readme-with-blog:
name: Update this repo's README with latest blog posts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gautamkrishnar/blog-post-workflow@master
with:
feed_list: "https://dev.to/feed/gautamkrishnar,https://www.gautamkrishnar.com/feed/"
- 将上面的 URL 列表替换为您自己的 RSS 源 URL。请参阅popular-sources获取常用 RSS 源 URL 列表。
- 提交并等待它自动运行,或者您也可以手动触发它以立即查看结果。要手动触发工作流程,请按照视频中的步骤操作。
选项
此工作流程包含其他选项,您可以根据自己的用例进行自定义。以下是可用选项的列表:
选项 | 默认值 | 描述 | 必需的 |
---|---|---|---|
feed_list |
"" |
以逗号分隔的 RSS 源 URL 列表,例如:https://example1.com,https://example2.com |
是的 |
max_post_count |
5 |
您希望在自述文件中显示的帖子的最大数量(所有动态合并) | 不 |
readme_path |
./README.md |
您要更新的自述文件的路径 | 不 |
gh_token |
具有 repo 范围的 GitHub 令牌 | 使用此配置将工作流结果提交到 GitHub 的用户的令牌 | 不 |
comment_tag_name |
BLOG-POST-LIST |
允许您覆盖默认的注释标签名称(<!-- BLOG-POST-LIST:START --><!-- BLOG-POST-LIST:END --> ),如果您想在同一个 repo 上显示该操作的多个实例,请参阅高级用法以获取更多信息 |
不 |
disable_sort |
false |
禁用基于发布日期的列表排序 | 不 |
template |
default |
允许您使用不同的变量更改帖子列表的结构。默认情况下,此工作流使用 Markdown 列表格式来呈现帖子,您可以使用此选项覆盖此行为。例如:[$title]($url) 将为您提供以空格分隔的帖子列表。支持的变量 |
不 |
date_format |
UTC:ddd mmm dd yyyy h:MM TT |
允许你更改使用模板选项中的 $date 时显示的日期或时间的格式。此功能使用 NPM dateformat 库,请阅读库文档了解支持的格式。 | 不 |
user_agent |
rss-parser |
允许您自定义 RSS 源爬虫使用的用户代理 | 不 |
accept_header |
application/rss+xml |
允许您自定义 http 请求的接受标头 | 不 |
tag_post_pre_newline |
true 如果您不使用模板选项 |
如果需要,可以在使用模板选项时在结束标记之前和开始标记之后插入换行符,以获得更好的格式 | 不 |
filter_comments |
medium,stackoverflow/Comment by $author/,stackexchange/Comment by $author/ |
您想要启用评论过滤器的平台列表(以逗号分隔)。 可用的过滤器 |
不 |
custom_tags |
"" |
允许您在模板中使用来自 Feed 项目的自定义标签。格式:variableName/tagName/,variableName/tagName/ 。请参阅问题评论了解更多详情 |
不 |
title_max_length |
"" |
允许您修剪帖子列表中的标题,多余的文本将以省略号结尾... |
不 |
description_max_length |
"" |
允许您修剪帖子列表中的描述,多余的文本将以省略号添加... |
不 |
item_exec |
"" |
允许您对从 XML 获取的每个帖子条目执行自定义 JavaScript 代码,以进行高级文本操作。请参阅问题评论中的示例。 | 不 |
commit_message |
Updated with the latest blog posts |
允许您自定义提交消息 | 不 |
committer_username |
blog-post-bot |
允许您自定义提交者用户名 | 不 |
committer_email |
blog-post-bot@example.com |
允许您自定义提交者电子邮件 | 不 |
output_only |
false |
将生成的数组设置为results 输出变量,以便它可以在其他操作中使用,并通过jq等实用程序进行解析。这也可以避免提交到 readme 文件。有关输出格式及其使用方法的更多详细信息,请参阅#51 。 |
不 |
enable_keepalive |
true |
如果过去 50 天内没有任何提交活动,Workflow 将自动执行虚拟提交以保持仓库处于活动状态。如果仓库超过 60 天处于非活动状态,GitHub 将停止运行所有基于 cron 的触发器。此标志允许您禁用此功能。有关更多详细信息,请参阅#53 。 | 不 |
retry_count |
0 |
如果失败,重试获取操作的最大次数,有关更多详细信息,请参阅#66 。 | 不 |
retry_wait_time |
1 |
每次重试操作之前等待的时间(以秒为单位)。 | 不 |
高级用法示例
StackOverflow 示例
以下配置允许您在 Github 个人资料或项目自述文件中显示最新的 StackOverflow 活动以及最新的博客文章:
- 按照“如何使用”部分中提到的步骤进行操作
- 将以下部分添加到您的README.md文件中,您可以输入任何标题。只需确保
<!-- STACKOVERFLOW:START --><!-- STACKOVERFLOW:END -->
在 readme 文件中使用即可。工作流会将此注释替换为实际的 StackOverflow 活动:
# StackOverflow Activity
<!-- STACKOVERFLOW:START -->
<!-- STACKOVERFLOW:END -->
stack-overflow-workflow.yml
在您的文件夹中创建workflows
以下内容,将4214976替换为您的 StackOverflow用户 ID:
name: Latest stack overflow activity
on:
schedule:
# Runs every 5 minutes
- cron: '*/5 * * * *'
workflow_dispatch:
jobs:
update-readme-with-stack-overflow:
name: Update this repo's README with latest activity from StackOverflow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gautamkrishnar/blog-post-workflow@master
with:
comment_tag_name: "STACKOVERFLOW"
commit_message: "Updated readme with the latest stackOverflow data"
feed_list: "https://stackoverflow.com/feeds/user/4214976"
查看结果!
热门来源
以下是一些流行的博客平台及其 RSS 提要网址的列表:
姓名 | 订阅源 URL | 评论 | 例子 |
---|---|---|---|
Dev.to | https://dev.to/feed/username |
将用户名替换为您自己的用户名 | https://dev.to/feed/gautamkrishnar |
WordPress | https://www.example.com/feed/ |
替换为您自己的博客网址 | https://www.gautamkrishnar.com/feed/ |
中等的 | https://medium.com/feed/@username |
将 @username 替换为您的 Medium 用户名 | https://medium.com/feed/@khaosdoctor |
中(子域名) | https://username.medium.com/feed |
将用户名替换为您的 Medium 用户名 | https://timsneath.medium.com/feed |
Stackoverflow | https://stackoverflow.com/feeds/user/userid |
替换为您的 StackOverflow UserId | https://stackoverflow.com/feeds/user/5283532 |
StackExchange | https://subdomain.stackexchange.com/feeds/user/userid |
替换为您的 StackExchange UserId和子域名 | https://devops.stackexchange.com/feeds/user/15 |
鬼 | https://www.example.com/rss/ |
替换为您自己的博客网址 | https://blog.codinghorror.com/rss/ |
Drupal | https://www.example.com/rss.xml |
替换为您自己的博客网址 | https://www.arsenal.com/rss.xml |
YouTube播放列表 | https://www.youtube.com/feeds/videos.xml?playlist_id=playlistId |
替换playlistId 为您自己的 Youtube 播放列表 ID |
https://www.youtube.com/feeds/videos.xml?playlist_id=PLJNqgDLpd5E69Kc664st4j7727sbzyx0X |
Youtube 频道视频列表 | https://www.youtube.com/feeds/videos.xml?channel_id=channelId |
替换channelId 为您自己的 Youtube 频道 ID |
https://www.youtube.com/feeds/videos.xml?channel_id=UCDCHcqyeQgJ-jVSd6VJkbCw |
Anchor.fm 播客 | https://anchor.fm/s/podcastId/podcast/rss |
您可以按照以下说明获取播客的 RSS 源 URL | https://anchor.fm/s/1e784a38/podcast/rss |
哈希节点 | https://@username.hashnode.dev/rss.xml |
将 @username 替换为您的 Hashnode 用户名 | https://polilluminato.hashnode.dev/rss.xml |
Google 播客 | https://podcasts.google.com/feed/channelId |
替换channelId 为您的 Google 播客频道 ID |
https://podcasts.google.com/feed/aHR0cHM6Ly9mZWVkcy5zb3VuZGNsb3VkLmNvbS91c2Vycy9zb3VuZGNsb3VkOnVzZXJzOjYyOTIxMTkwL3NvdW5kcy5yc3M= |
http://www.reddit.com/r/topic/.rss |
您可以通过在现有 Reddit 网址末尾添加“.rss”来创建 RSS 源。请将其替换topic 为您感兴趣或本地化的 SubReddit 主题。 |
http://www.reddit.com/r/news/.rss | |
《印度分析》杂志 | https://analyticsindiamag.com/author/author_name/feed/ |
author_name 用你的名字替换 |
https://analyticsindiamag.com/author/kaustubhgupta1828gmail-com/feed/ |
Feedburner | https://feeds.feedburner.com/feed_address |
替换feed_address 为您的 Feedburner feed 地址 |
https://feeds.feedburner.com/darkwood-fr/blog |
Tumblr | https://blog_name.tumblr.com/rss 或者https://example.com/rss |
您可以通过将“/rss”添加到您的博客主页面或您自己的域名(如果已配置)来创建 RSS 源。将其替换blog_name 为您的博客名称 |
https://goggledoddle.tumblr.com/rss |
示例
2020年7月22日更新
感谢大家的热烈响应,我们刚刚为项目添加了 StackOverflow 支持。现在,您可以在 GitHub 自述文件中查看您的 dev.to 帖子以及 StackOverflow 活动。该操作现在支持在同一个仓库中创建多个实例。请参阅示例自述文件:
文章来源:https://dev.to/gautamkrishnar/show-your-latest-dev-to-posts-automatically-in-your-github-profile-readme-3nk8