Skip to content
This repository has been archived by the owner on Oct 7, 2018. It is now read-only.

Script to seed Discourse with Collectives, Groups and Tags for the Debt Collective community

License

Notifications You must be signed in to change notification settings

debtcollective/discourse-seed

Repository files navigation

Module for seeding the Debt Syndicate's Discourse instances with Collectives, User Groups, Wikis, Settings, and anything else we need to bend Discourse to our purposes.

Guidance for contributors

If you need to make a new endpoint accessible in the discourse-node-api you may mask the request by using the auth<METHOD> functions exposed by the DiscourseApi instance until your PR in the discourse-node-api is merged and available for use.

Any unhandled error will kill the script, so handle them early if you expect them.

Discourse API docs are here. The docs are kinda bad though, so the best thing to do is use Wireshark and sniff an API call after making it manually through the front-end and mimicking that through the Discourse API. Most endpoints work using the same exact route that the front-end uses. If it doesn't, try putting .json on the end of the route. More information about reverse-engineering the API here. The main pain-point of the documentation is that almost none of the interesting properties that are editable in a PUT or POST are documented, so the best thing to do really is to figure it out through reverse engineering and not waste your time with the documentation unless you're going to contribute to them (maybe once we have time we'll do that and make the Discourse API docs real nice to use).

Open a PR, get it reviewed and approved by a maintainer and once it is merged the CI will seed staging once a maintainer removes the CI hold. 🎊

Secret Variables

This script requires a couple secrets to work. Really only two of these is a secret but 🤷‍♀️. These all have defaults in the script but you'll need to update the API key and the SSO secret. See step 2, below.

Steps for enabling in new Discourse environments

  1. Generate an API key for the system user (Admin Dashboard -> Users -> system -> generate API key)
  2. Copy secrets.sample to secrets.<env>.js and fill in the correct values.
  3. Upload the secrets file to tdc-secure S3 bucket ensuring public access is OFF. Only the CI policy will have access to this file.
  4. Create a job in the CI workflow for the environment, mirroring how the other environments have it. Note that seed.sh takes a single variable of the environment which should match the <env> part of the secrets.<env>.js from before
  5. Restrict that job to a specific branch.
  6. Push that branch and release the hold in Circle CI for that build.
  7. Success!

About

Script to seed Discourse with Collectives, Groups and Tags for the Debt Collective community

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published