From a68d5e7caf9de6743b32e2cd4a126b016da2af1d Mon Sep 17 00:00:00 2001 From: Evaldo Felipe Date: Wed, 8 Jan 2025 16:03:54 -0300 Subject: [PATCH] improve: Add external config Signed-off-by: Evaldo Felipe --- package.json | 3 ++- scripts/pre-build-env.sh | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 scripts/pre-build-env.sh diff --git a/package.json b/package.json index 67a167b89..284d6399b 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,9 @@ "scripts": { "start": "export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && vite", "dev": "export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && vite --port $PORT --host", - "build": "yarn prebuild && export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && tsc && vite build", + "build": "yarn prebuild-env && yarn prebuild && export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && tsc && vite build", "prebuild": "tsx scripts/pre-build.ts", + "prebuild-env": "./scripts/pre-build-env.sh && source output.env", "analyze": "yarn build && rollup-plugin-visualizer --open ./bundle-size-analysis.json", "test": "export REACT_APP_GIT_COMMIT_HASH=$(git rev-parse HEAD) && jest --env jsdom src", "serve": "vite preview --port 3000", diff --git a/scripts/pre-build-env.sh b/scripts/pre-build-env.sh new file mode 100755 index 000000000..3fba2d04d --- /dev/null +++ b/scripts/pre-build-env.sh @@ -0,0 +1,18 @@ +#!/bin/bash + + set -o errexit + set -o nounset + + FILE_REMOTE="projects/across/frontend/outputs/output.env" + FILE_PATH="output.env" + GH_REPO="UMAprotocol/git-env" + + if [ -n "${GH_TOKEN}" ]; then + echo "Getting env files from config repo..." + curl -o ${FILE_PATH} "https://${GH_TOKEN}@${GH_REPO}/${FILE_REMOTE}" + echo "Updated data at ${FILE_PATH}" + echo $GIT_ENV_EXPORTED + echo "Done!" + else + echo "No env exported" + fi