From 7748679698b0a6e89b28cb19d7851dd04398c20d Mon Sep 17 00:00:00 2001 From: Erick Almeida Date: Thu, 14 Apr 2022 13:08:55 -0500 Subject: [PATCH] fix: TT-610 Fix pipeline - read from OS env variable in .ts --- .github/workflows/CI-time-tracker-ui.yml | 4 ++-- package.json | 2 +- scripts/populate-var-file.sh | 10 ++++++++++ scripts/setenv.ts | 15 ++++++++------- 4 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 scripts/populate-var-file.sh diff --git a/.github/workflows/CI-time-tracker-ui.yml b/.github/workflows/CI-time-tracker-ui.yml index da410589a..f63625e00 100644 --- a/.github/workflows/CI-time-tracker-ui.yml +++ b/.github/workflows/CI-time-tracker-ui.yml @@ -48,8 +48,8 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }} run: | - chmod +x ./scripts/populate-keys.sh - sh ./scripts/populate-keys.sh + chmod +x ./scripts/populate-var-file.sh + sh ./scripts/populate-var-file.sh - name: Running tests run: npm run ci-test --if-present diff --git a/package.json b/package.json index 733159dd0..396d1b3fe 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "ng build --prod", "test": "ng test --browsers ChromeHeadless", "test-headless": "ng test --browsers ChromeHeadless", - "ci-test": "npm run config && ng test --no-watch --no-progress --browsers ChromeHeadless", + "ci-test": "ng test --no-watch --no-progress --browsers ChromeHeadless", "lint": "ng lint", "e2e": "ng e2e" }, diff --git a/scripts/populate-var-file.sh b/scripts/populate-var-file.sh new file mode 100644 index 000000000..f395689af --- /dev/null +++ b/scripts/populate-var-file.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +> src/environments/keys.ts +echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts +echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts +echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts +echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts +echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts +echo 'export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = "'$AZURE_APP_CONFIGURATION_CONNECTION_STRING'";' >> src/environments/keys.ts +cat src/environments/keys.ts diff --git a/scripts/setenv.ts b/scripts/setenv.ts index 9bc3b5069..2a8703921 100644 --- a/scripts/setenv.ts +++ b/scripts/setenv.ts @@ -1,14 +1,13 @@ const { writeFile } = require('fs'); -require('dotenv').config(); const pathJs = `./src/environments/keys.ts` const contentKeys = -`export const AUTHORITY = '${process.env.AUTHORITY}'; -export const CLIENT_ID = '${process.env.CLIENT_ID}'; -export const SCOPES = ['${process.env.SCOPES}']; -export const STACK_EXCHANGE_ID = '${process.env.STACK_EXCHANGE_ID}'; -export const STACK_EXCHANGE_ACCESS_TOKEN = '${process.env.STACK_EXCHANGE_ACCESS_TOKEN}'; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${process.env.AZURE_APP_CONFIGURATION_CONNECTION_STRING}'; +`export const AUTHORITY = '${process.env["AUTHORITY"]}'; +export const CLIENT_ID = '${process.env["CLIENT_ID"]}'; +export const SCOPES = ['${process.env["SCOPES"]}']; +export const STACK_EXCHANGE_ID = '${process.env["STACK_EXCHANGE_ID"]}'; +export const STACK_EXCHANGE_ACCESS_TOKEN = '${process.env["STACK_EXCHANGE_ACCESS_TOKEN"]}'; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]}'; `; writeFile(pathJs, contentKeys, function (err) { @@ -16,6 +15,8 @@ writeFile(pathJs, contentKeys, function (err) { console.log(err); } console.log(`Wrote variables to ${pathJs}`); + console.log(`Wrote variables to ${process.env["SCOPES"]}`); + console.log(`Wrote variables to ${process.env["STACK_EXCHANGE_ID"]}`); }); const pathJson = `./src/environments/.keys.json`