A (somewhat) simple github action that generates a set of cards for recent blog posts.
Here's an example of how it looks given the URLs for DEV Community, JavaScript Weekly, and Echo JS:
The most recent home feed on DEV Community 👩💻👨💻.
Last updated: Wednesday, October 12, 2022 at 7:09:31 PM
Showing 5 of 12 posts.
A newsletter of JavaScript articles, news and cool projects
Last updated: Wednesday, October 12, 2022 at 7:09:35 PM
Showing 4 of 4 posts.
Description pending
Last updated: Wednesday, October 12, 2022 at 7:09:40 PM
Showing 5 of 30 posts.
This action runs out-of-the-box, with only one provided input.
Create a .yml
file with the desired filename, and paste the following:
on:
push:
schedule:
- cron: "0 */6 * * *"
jobs:
blog:
runs-on: ubuntu-latest
name: Fetch and Generate Blog Posts
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate
uses: ErrorGamer2000/github-readme-blog-post-action@v1
with:
feed_urls: FEEDS
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Save Generated Blog Posts
skip_checkout: true
Replace the FEEDS with a comma-seperated list of RSS feed URLs, add
<!-- blog-post-list:start -->
<!-- blog-post-list:end -->
in the README where you want the list, and BAM! You have yourself an automatic action that runs every 6 hours and when you change any of the files in your readme!
Option Name | Type | Default Value | Description |
---|---|---|---|
feed_urls |
string |
"" |
A (comma-seperated) list of RSS feed URLs to load posts from. This is the only required input. |
max_posts_per_url |
number |
5 |
The maximum number of posts to show for each feed. If the number of posts is less than this, then all of the posts will be shown. |
position_indicator |
string |
blog-post-list |
The text of the comments that the action uses to inject the images into the README file. Everything between the two comments in the form <!-- position_indicator:start --> and <!-- position_indicator:end --> is replaced. Changing this can allow you to use multiple configurations for different feeds by using different markers for each. |
show_feed_data |
boolean |
true |
Whether or not to show the generated markdown describing the feed, which includes the title of the feed, the description of the feed, the Read More link, the last updated date, and the post count. Each of these can also be individually toggled with the following options. This will override any of the specific options, so it is better to disable/enable them specifically if you want to remove some elements. |
show_feed_title |
boolean |
true |
Whether or not to show the header containing the title of the feed. This will be formatted as an h2 header. An option to customize this header will be in a future update. |
show_feed_description |
boolean |
true |
Whether or not to show the title of the feed that is provided by the RSS feed. |
show_read_more |
boolean |
true |
Whether or not to show the Read More link under the feed description. |
show_last_updated_date |
boolean |
true |
Whether or not to show the date and time of the last update of the list. |
show_post_count |
boolean |
true |
Whether or not to show the number of posts shown and the total number of posts provided by the RSS feed. |
show_post_date |
boolean |
true |
Whether or not to show the date of each post on the card. |
locale |
string |
"en" |
The locale of the project. This is used purely for formatting the dates of the cards and last update. |
time_zone |
string |
"UTC" |
A valid time zone to use for the last updated date. |
output_dir |
string |
"blog-post-list-output" |
The directory to store the post card images in. Must be in the root directory (i.e. no path separators / or \ ) and cannot include the characters /\?%*:|"<> . |
- Make sure that you use an action that will commit changed files to the repository after this action has run, so that the files actually get changed.
- I am a solo dev, and will get back to you as soon as I can, so expect to wait several weeks depending on how many other issues there are.
- Enjoy and share! 🤗