Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .configref
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18036
27 changes: 27 additions & 0 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Config
on: [push]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
sync:
name: Check for config changes
runs-on: ubuntu-latest
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v19
with:
files: |
server/src/configs/default.json
- name: Run step if any of the listed files above change
if: steps.changed-files.outputs.any_changed == 'true'
run: |
yarn config-check
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"missing-locales": "node server/scripts/createLocales.js --missing",
"create-area": "node server/scripts/poracleToGeoJSON.js",
"config-migrate": "node server/scripts/configMigration.js",
"config-check": "node server/scripts/configCheck.js",
"console": "node --experimental-repl-await ./server/scripts/console.js",
"migrate:make": "knex --knexfile server/knexfile.cjs migrate:make",
"migrate:latest": "knex --knexfile server/knexfile.cjs migrate:latest",
Expand Down
12 changes: 12 additions & 0 deletions server/scripts/configCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const fs = require('fs')
const path = require('path')

fs.writeFileSync(
path.resolve(__dirname, '../../.configref'),
fs
.readFileSync(
path.resolve(__dirname, '../src/configs/default.json'),
'utf8',
)
.length.toString(),
)
22 changes: 22 additions & 0 deletions server/src/services/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@ dotenv.config()

const config = require('config')

try {
const refLength = +fs.readFileSync(
resolve(__dirname, '../../../.configref'),
'utf8',
)
const defaultLength = fs.readFileSync(
resolve(__dirname, '../configs/default.json'),
'utf8',
).length

if (refLength !== defaultLength) {
console.error(
'[CONFIG] It looks like you have modified the `default.json` file, you should not do this! Make all of your config changes in your `local.json` file.',
)
}
} catch (e) {
console.error(
'[CONFIG] Error trying to read either the default.json or .ref file',
e,
)
}

if (!fs.existsSync(resolve(`${__dirname}/../configs/local.json`))) {
// add database env variables from .env or docker-compose
const {
Expand Down