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