Browse Source

Move the config for the CI to a file and then create separate configs for each environment, finally allowing knex to automatically update the correct environment.

master
Zed A. Shaw 1 week ago
parent
commit
e518857010
1 changed files with 4 additions and 22 deletions
  1. +4
    -22
      scripts/services/ci.js

+ 4
- 22
scripts/services/ci.js View File

@@ -9,25 +9,7 @@ const pm2 = require('pm2');
const waitOn = require('wait-on');
const assert = require('assert');
const simpleGit = require('simple-git/promise');
const readdirp = require('readdirp');
const path = require('path');

const config = {
private: '../ljsthw-private/',
testing_target: 'deployment/testing',
build_target: 'deployment/production',
deploy_target: '/mnt/www/share',
fixtures: '__tests__/fixtures',
dev_server_wait: {
resources: ['http://localhost:3000'], delay: 1000, timeout: 60000
},
gzip_filter: ['!index.html', '*.css', '*.js', '*.html', '*.svg', '*.json'],
prod_server_wait: {
resources: ['http://localhost:7778'], delay: 1000, timeout: 30000
},
db_repo_name: 'ljsthw-private',
code_repo_name: 'learnjsthehardway',
}
const config = require('../../ci.config')[secrets.env];

const pm2_do = (action, name) => {
log.debug(`Restarting the ${name} process.`);
@@ -97,7 +79,7 @@ exports.needs_sql_migrations = build.rule('needs sql migrations', {
f => f.code_git_pull && f.code_git_pull.files.filter(x => x.startsWith('migrations')).length > 0
],
then: async f => {
build.exec('npx knex migrate:latest');
build.exec(`npx knex migrate:latest --env ${config.knex_env}`);
f.migrations_ran = true;
}
});
@@ -126,7 +108,7 @@ exports.needs_prod_media = build.rule('needs production media', {
}

// need to make sure the production dir is there
build.mkdir(config.build_target); // TODO: make it so mkdir will make the whole path
build.mkdir(config.build_target);

log.debug(`Creating symlink protected to ${config.build_target}`);
await fs.symlink(config.build_target, 'protected');
@@ -171,7 +153,7 @@ exports.needs_restart = build.rule('needs production restart', {
});

exports.needs_www_push = build.rule('needs results pushed to www', {
when: f=> f.build_complete,
when: f => f.build_complete,
then: async f => {
build.exec(`rsync -av --delete public/* static/* ${config.deploy_target}/`);
build.exec(`rsync -av --delete __sapper__/build/client ${config.deploy_target}/`);


Loading…
Cancel
Save