From e2245dd9c0c68b2d7043aec6cbac6ef54af28973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Wed, 31 May 2017 11:32:15 +0100 Subject: [PATCH] chore: create triton profile on deploy script --- circle.yml | 2 -- scripts/deploy | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index 02309b30..d10c78ed 100644 --- a/circle.yml +++ b/circle.yml @@ -34,8 +34,6 @@ deployment: - sudo chmod +x /usr/local/bin/docker-compose # install and setup triton - yarn global add triton@4.15.0 || cat /home/ubuntu/.yarn-config/global/yarn-error.log - - echo '{"url":"https://eu-ams-1.api.joyent.com", "account":"'$SDC_ACCOUNT'", "keyId":"'$SDC_KEY_ID'", "name":"eu-ams-1", "curr":true}' | triton profile create -f - - - triton env --docker eu-ams-1 development: branch: master diff --git a/scripts/deploy b/scripts/deploy index bf6a3831..e31900a6 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -15,7 +15,27 @@ const NAMESPACE = 'quay.io/yldio'; const ROOT = path.join(__dirname, '..'); const LOG = console.log; +const createTritonProfile = async ({ SDC_ACCOUNT = '', SDC_KEY_ID = '' }) => { + LOG(`${figures.arrowRight} create triton profile SDC_ACCOUNT=${SDC_ACCOUNT.length} SDC_KEY_ID=${SDC_KEY_ID.length}`); + + const payload = JSON.stringify({ + url: 'https://eu-ams-1.api.joyent.com', + account: SDC_ACCOUNT, + keyId: SDC_KEY_ID, + name: 'eu-ams-1', + curr: true + }); + + const cp = execa('triton', ['profile', 'create', '-f', '-']); + + cp.stdin.write(payload); + + return cp; +}; + const getEnv = async () => { + await createTritonProfile(process.env); + const tritonEnv = await execa.stdout('triton', ['env']); const dotEnv = tritonEnv.replace(/^export /gim, ''); return Object.assign({}, process.env, parse(dotEnv));