eduardoboucas / staticman

💪 User-generated content for Git-powered websites
https://staticman.net
MIT License
2.41k stars 534 forks source link

Improve support for multiple environments (e.g., dev, staging, prod) #416

Open hispanic opened 3 years ago

hispanic commented 3 years ago

Staticman is architected with two configuration files:

  1. A YAML-formatted "site/repo" file that is meant to be found in a git service (such as GitHub or GitLab).
  2. A JSON-formatted "server" file (which may be overridden/supplemented using environmental variables).

With this architecture, multiple web sites (each with their own source git repository) may leverage a single "community" Staticman instance. Unfortunately, this architecture hinders the implementation of a more "robust" development lifecycle that features promotion through, for example, development, test, staging, and production environments.

For example, the schema for the YAML-formatted "site/repo" file currently requires that a value be set for the branch property and defaults to master. However, this precludes the ability for the YAML-formatted "site/repo" file to be promoted, without change, on the way to production. Similarly, with Staticman currently only allowing for Akismet to be enabled/disabled via the akismet.enabled property in the YAML-formatted "site/repo" file, Akismet cannot be cleanly disabled in dev or test (but remain enabled in prod) without requiring a modification to source code during code promotion.

In order to address this shortcoming, several properties should be added to the schema for the JSON-formatted "server" file, which could be shadowed by their YAML-formatted "site/repo" file counterparts:

The goal would be to allow for any environment-specific configuration to be specified someplace other than the YAML-formatted "site/repo" file.

Once support for multiple environments is improved, a follow-on concern is cross-talk between tiers/layers of different environments. For example:

In order to prevent/identify this cross-talk, logic checks should be added to the codebase. For example:

Beyond preventative steps, the various artifacts generated by Staticman could be "tagged" with their source environment. For example:

This would make it obvious which notification emails, pull/merge requests, and mailing lists are aligned with which environments.