Pawel Grzybek has set up a workflow that uses GitHub Actions’ Scheduled Events to automatically update his profile README.md
. It runs every 6 hours and pulls in his RSS feed to populate the README.md
import fs from "fs";
import fetch from "node-fetch";
import parser from "xml2json";
const FEED_URL = "https://pawelgrzybek.com/feed.xml";
const TAG_OPEN = `<!-- FEED-START -->`;
const TAG_CLOSE = `<!-- FEED-END -->`;
const fetchArticles = async () => {
const articles = await fetch(FEED_URL);
const articlesText = await articles.text();
const articlesJSON = parser.toJson(articlesText);
const newC = JSON.parse(articlesJSON).rss.channel.item.slice(0, 5);
return newC.map(({ title, link }) => `- [${title}](${link})`).join("\n");
};
async function main() {
const readme = fs.readFileSync("./README.md", "utf8");
const indexBefore = readme.indexOf(TAG_OPEN) + TAG_OPEN.length;
const indexAfter = readme.indexOf(TAG_CLOSE);
const readmeContentChunkBreakBefore = readme.substring(0, indexBefore);
const readmeContentChunkBreakAfter = readme.substring(indexAfter);
const posts = await fetchArticles();
const readmeNew = `
${readmeContentChunkBreakBefore}
${posts}
${readmeContentChunkBreakAfter}
`;
fs.writeFileSync("./README.md", readmeNew.trim());
}
try {
main();
} catch (error) {
console.error(error);
}
Fetch most recent posts to your GitHub profile page using GitHub workflow and Node.js →
💡 People have been doing lots of nice stuff with their README’s. There’s a curated list to be found at matiassingers/awesome-readme
(and plenty of others if you search for them)