forked from forwardemail/forwardemail.net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ansible-playbook.js
31 lines (23 loc) · 921 Bytes
/
ansible-playbook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const parse = require('parse-git-config');
const env = path.join(__dirname, '.env.production');
if (!fs.existsSync(env))
throw new Error(`.env.production file missing: ${env}`);
if (!fs.statSync(env).isFile())
throw new Error(`.env.production file missing: ${env}`);
// this will populate process.env with
// environment variables from dot env file
require('@ladjs/env')({
path: env,
defaults: path.join(__dirname, '.env.defaults'),
schema: path.join(__dirname, '.env.schema')
});
// set git config url
process.env.GITHUB_REPO = parse.sync({
path: path.join(__dirname, '.git', 'config')
})['remote "origin"'].url;
if (!execSync('which ansible-playbook'))
throw new Error('ansible-playbook is required to be installed on this os');
execSync(`ansible-playbook ${process.argv.slice(2).join(' ')}`);