GitHub Action that updates a README file with a table of the latest blog posts read from a local checkout of a Markdown blog-posts repository (with YAML frontmatter).
This action does not call any external HTTP API. The consumer workflow is responsible for checking out the blog-posts repository and passing its path to this action via POSTS_DIR.
| Input | Required | Default | Description |
|---|---|---|---|
POSTS_DIR |
yes | — | Path to the local directory containing the Markdown blog posts (with frontmatter). |
BLOG_BASE_URL |
no | https://davidmontesdeoca.dev |
Base URL of the published blog. Each post URL is ${BLOG_BASE_URL}/${slug}. |
README_FILE |
no | ./README.md |
Path to the README file to update. |
OPENING_COMMENT |
no | <!-- HASHNODE_POSTS:START --> |
Marker for the start of the section to replace. |
CLOSING_COMMENT |
no | <!-- HASHNODE_POSTS:END --> |
Marker for the end of the section to replace. |
MAX_POSTS |
no | 5 |
Number of posts to render. |
COMMIT_MESSAGE |
no | chore(docs): update recent blog posts |
Commit message used when changes are pushed. |
Each Markdown file in POSTS_DIR must include a YAML frontmatter block with the following fields:
---
title: "Post title"
seoDescription: "Short description used as the brief."
datePublished: 2023-04-12T06:54:23.322Z
slug: post-slug
cover: https://example.com/cover.png
---Files missing any of these fields are skipped with a warning.
name: Update latest blog posts
on:
workflow_dispatch:
repository_dispatch:
types: [blog-posts-updated]
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout profile repo
uses: actions/checkout@v7
- name: Checkout blog-posts repo
uses: actions/checkout@v7
with:
repository: backpackerhh/blog-posts
path: .blog-posts
ref: main
- name: Update README with latest posts
uses: backpackerhh/github-latest-blog-posts@main
with:
POSTS_DIR: .blog-posts