jekyll / jekyll-feed

:memo: A Jekyll plugin to generate an Atom (RSS-like) feed of your Jekyll posts
MIT License
836 stars 203 forks source link

Option to skip generating feed if no site content changed #387

Closed vincerubinetti closed 1 year ago

vincerubinetti commented 1 year ago

Apologies if there's already an issue for this or if I'm misunderstanding.

Currently, this plugin seems to always add the date-time when the site was built, regardless of whether any content of the site changed. This has the unfortunate side effect of making your site build non-deterministic. That is, building your site will always produce a change/diff, even if the input source didn't change.

How this affects me is that in my CI/CD GitHub Actions workflows, I now have to manually check if there were any changes to the input source code, and only build the site if there were. This is to prevent unnecessary build-time, but also to prevent infinite CI/CD loops in some cases.

It'd be great if this plugin handled this automatically. Maybe Jekyll provides a plugin with some sort of information about what source code has changed?

vincerubinetti commented 1 year ago

Each time the plugin is run, you could compare the newly generated feed to the old one and see if anything (besides the date) changed before actually outputting the results or updating the date. But to accomplish this, you'd need to have access to the previous feed, which now that I think about it, is probably rare for most people's use cases. The built site is probably being pushed to another branch e.g. gh-pages and being discarded on the current branch.

Still though, the plugin could check locally for the previous feed just in case, or even take an option that's a URL to the previous feed, say on a deployed GitHub Pages site.

ashmaroli commented 1 year ago

Hello @vincerubinetti, The default site builds are atomic; as in the whole site is rebuilt on every incantation of jekyll build irrespective of file changes. The only time Jekyll core even slightly considers "deterministic" build is when the build is run with CLI flag --incremental or incremental: true config entry. Even then, generator-based plugins such as jekyll-feed or jekyll-sitemap are unaffected.

vincerubinetti commented 1 year ago

Okay if the whole tool takes that philosophy I guess it doesn't make sense for one plugin to make an exception.

I just found it weird since this was the first case I ran into (in many years of using Jekyll) of it not being deterministic, only due to the date.