Skip to content

Commit

Permalink
Update Build Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Dec 26, 2024
1 parent 9694c9c commit aa90108
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
43 changes: 35 additions & 8 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ import CP from 'child_process';

process.env.GITSHA = sha();

for (const env of ['GITSHA', 'AWS_REGION', 'AWS_ACCOUNT_ID']) {
process.env.API_URL = process.env.API_URL || '"https://example.com"';
process.env.Environment = process.env.Environment || 'prod'

Check failure on line 7 in build.js

View workflow job for this annotation

GitHub Actions / test

Missing semicolon

for (const env of [
'GITSHA',
'AWS_REGION',
'AWS_ACCOUNT_ID',
'Environment',
'API_URL'
]) {
if (!process.env[env]) {
console.error(`${env} Env Var must be set`);
process.exit();

Check warning on line 18 in build.js

View workflow job for this annotation

GitHub Actions / test

Don't use process.exit(); throw an error instead
Expand All @@ -12,20 +21,22 @@ for (const env of ['GITSHA', 'AWS_REGION', 'AWS_ACCOUNT_ID']) {

await login();


if (!process.argv[2]) {
console.error('ok - building all containers');

await api();
await cloudtak_api();
await cloudtak_ui();

for (const dir of await fs.readdir(new URL('./tasks/', import.meta.url))) {
await task(dir);
await cloudtak_task(dir);
}
} else {
if (process.argv[2] === 'api') {
await api();
await cloudtak_api();
} else if (process.argv[2] === 'ui') {
await cloudtak_ui();
} else {
await task(process.argv[2]);
await clodutak_task(process.argv[2]);

Check failure on line 39 in build.js

View workflow job for this annotation

GitHub Actions / test

'clodutak_task' is not defined
}
}

Expand All @@ -49,7 +60,7 @@ function login() {

}

function api() {
function cloudtak_api() {
return new Promise((resolve, reject) => {
const $ = CP.exec(`
docker compose build api \
Expand All @@ -65,7 +76,23 @@ function api() {
});
}

async function task(task) {
function cloudtak_ui() {
return new Promise((resolve, reject) => {
const $ = CP.exec(`
cd api/web/ \
&& npm run builds3 \
&& aws s3 cp --recursive "dist/" "s3://coe-etl-$\{Environment\}-$\{AWS_ACCOUNT_ID\}-$\{AWS_REGION\}-public/$\{GITSHA\}/"
`, (err) => {
if (err) return reject(err);
return resolve();
});

$.stdout.pipe(process.stdout);
$.stderr.pipe(process.stderr);
});
}

async function cloudtak_task(task) {
process.env.TASK = task;

return new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion cloudformation/webhooks.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default cf.merge(
Default: 'prod'
},
HostedURL: {
Description: 'URL of domain/subdomain at which the API is hosted ie: "map.example.com"',
Description: 'URL of domain/subdomain at which the API is hosted ie: "webhooks.example.com"',
Type: 'String'
},
SSLCertificateIdentifier: {
Expand Down

0 comments on commit aa90108

Please sign in to comment.