Skip to content

Commit 18457c7

Browse files
committed
PEER-226: Ban committing key
Signed-off-by: SeeuSim <[email protected]>
1 parent 6e99813 commit 18457c7

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11

22
npx lint-staged
3+
4+
"$(pwd)/scripts/inject-openai-key.sh"

frontend/.env.local

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ VITE_QUESTION_SERVICE=http://localhost:9002
55
VITE_COLLAB_SERVICE=http://localhost:9003
66
VITE_MATCHING_SERVICE=http://localhost:9004
77
VITE_CHAT_SERVICE=http://localhost:9005
8-
OPENAI_API_KEY=PUT_YOUR_OPENAI_API_KEY_HERE

scripts/inject-openai-key.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
NEW_KEY="$1"
4+
if [ $# -ne 1 ]; then
5+
NEW_KEY="<insert_key>"
6+
fi
7+
8+
# Check if we're on macOS
9+
if [[ "$OSTYPE" == "darwin"* ]]; then
10+
# macOS version (using empty '' after -i)
11+
find . -type f -name ".env*" -exec sed -i '' "s/OPENAI_API_KEY=.*/OPENAI_API_KEY=\"${NEW_KEY}\"/g" {} +
12+
else
13+
# Linux version
14+
find . -type f -name ".env*" -exec sed -i "s/OPENAI_API_KEY=.*/OPENAI_API_KEY=\"${NEW_KEY}\"/g" {} +
15+
fi

0 commit comments

Comments
 (0)