Skip to content

durinthal/reddit-wiki-sync

Repository files navigation

Reddit Wiki Sync

Save wiki pages of subreddits to a git repository! There's a rudimentary revision system on reddit, but it can only show the full page at any given revision or a diff between two revisions.

This allows for use of tools like git blame to figure out exactly when specific lines were changed without needing to crawl through a page's history and check multiple revisions.

Getting Started

  1. Create a new repository from this template.

  2. Enable write permissions for GITHUB_TOKEN in the repository.

  3. Set configuration variables and secrets for the repository following the below names.

  4. Enable the scheduled workflow if you want to have automatic updates and change the scheduled time if appropriate (default: 6:25 UTC every day).

Caveats and Reminders

  • If including mod-only pages you probably want to make sure your repository is private as well.
  • The initial sync may take several hours if the subreddit has a long history of revisions to wiki pages, so you might want to check out the repository to run it manually and not under Github Actions.
  • Specific pages can have many revisions and you may want to ignore them, such as usernotes if the subreddit uses Toolbox's user notes.
  • Delisted pages will remain even if the unlisted pages flag isn't set, they must be manually pruned.
  • As currently set up, this only works for one subreddit per repository. Modifying the workflows to take a subreddit as an input or use environments would be ways of handling multiple subreddits.

Environment Variables

  • SUBREDDIT_NAME_TO_ACT_ON: The name of the subreddit that has the wiki you wish to archive without the leading /r/, e.g. anime.
  • REDDIT_USERNAME: Name for authenticating reddit user.
  • REDDIT_CLIENT_ID: OAuth Client ID for authenticating app.
  • REDDIT_USER_AGENT: User Agent string for authenticating app.

For customizing the scheduled workflow also include these:

  • SCHEDULED_SYNC_PAGES: Comma-separated list of wiki page names to save, or all if *. (default *)
  • SCHEDULED_SYNC_IGNORE: Comma-separated list of wiki page names to ignore. (default: none)
  • SCHEDULED_SYNC_FULL: true to include all of a page's history rather than just recent updates. Ignores unlisted pages. (default: false)
  • SCHEDULED_SYNC_MOD: true to save mod-only pages as well, or just publicly visible pages if false. (default: false)
  • SCHEDULED_SYNC_UNLISTED: true to save unlisted pages as well, if checking recent revisions. Not compatible with full list. (default: false)

Environment Secrets

  • REDDIT_CLIENT_SECRET: OAuth Client Secret for authenticating app.
  • REDDIT_USER_PASSWORD: Password for authenticating reddit user.
  • REDDIT_TOTP_SECRET: (optional) Only add if the authenticating reddit user has two-factor authentication enabled.

About

Copy reddit wiki revisions to git commits.

Topics

Resources

License

Stars

Watchers

Forks

Languages