diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2720236fe..d2c20e352 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -300,14 +300,14 @@ jobs: kubectl -n default rollout restart deployment/ocelot-maintenance kubectl -n default set image deployment/ocelot-neo4j container-ocelot-neo4j=ocelotsocialnetwork/neo4j-community:$BUILD_VERSION kubectl -n default rollout restart deployment/ocelot-neo4j - - name: Verify deployment + - name: Verify deployment and wait for the pods of each deplyment to get ready for cleaning and seeding of the database run: | - kubectl -n default rollout status deployment/ocelot-backend --timeout=240s - kubectl -n default rollout status deployment/ocelot-neo4j --timeout=240s kubectl -n default rollout status deployment/ocelot-webapp --timeout=240s kubectl -n default rollout status deployment/ocelot-maintenance --timeout=240s + kubectl -n default rollout status deployment/ocelot-backend --timeout=240s + kubectl -n default rollout status deployment/ocelot-neo4j --timeout=240s - name: Reset and seed Neo4j database via backend for staging - # db cleaning is only possible if env 'PRODUCTION_DB_CLEAN_ALLOW=true' is set in deployment + # db cleaning and seeding is only possible in production if env 'PRODUCTION_DB_CLEAN_ALLOW=true' is set in deployment run: | kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "node dist/db/clean.js" kubectl -n default exec -it $(kubectl -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- /bin/sh -c "node dist/db/seed.js" diff --git a/backend/src/config/index.js b/backend/src/config/index.js index d6d8cc166..6ad8c578b 100644 --- a/backend/src/config/index.js +++ b/backend/src/config/index.js @@ -22,6 +22,8 @@ const environment = { DEBUG: env.NODE_ENV !== 'production' && env.DEBUG, TEST: env.NODE_ENV === 'test', PRODUCTION: env.NODE_ENV === 'production', + // used for staging enviroments if 'PRODUCTION=true' and 'PRODUCTION_DB_CLEAN_ALLOW=true' + PRODUCTION_DB_CLEAN_ALLOW: env.PRODUCTION_DB_CLEAN_ALLOW === 'true' || false, // default = false DISABLED_MIDDLEWARES: (env.NODE_ENV !== 'production' && env.DISABLED_MIDDLEWARES) || false, } diff --git a/backend/src/db/clean.js b/backend/src/db/clean.js index c55e31443..db4e10bdf 100644 --- a/backend/src/db/clean.js +++ b/backend/src/db/clean.js @@ -2,7 +2,7 @@ import { cleanDatabase } from '../db/factories' import CONFIG from '../config' if (CONFIG.PRODUCTION && !CONFIG.PRODUCTION_DB_CLEAN_ALLOW) { - throw new Error(`You cannot clean the database in production environment!`) + throw new Error(`You cannot clean the database in a non-staging and real production environment!`) } ;(async function () {