Skip to content

Commit 81abf07

Browse files
committed
Change some security things
1 parent c4b6305 commit 81abf07

File tree

3 files changed

+79
-58
lines changed

3 files changed

+79
-58
lines changed

.github/scripts/check_realtime_feeds.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import json
88
import sys
99
import time
10+
import os
1011
from pathlib import Path
1112
from typing import Dict, List, Tuple
1213
from urllib.parse import urlparse
@@ -35,7 +36,16 @@ def load_realtime_data(file_path: str = "realtime.json") -> Dict:
3536
"""Load and parse the realtime.json file"""
3637
try:
3738
with open(file_path, 'r', encoding='utf-8') as f:
38-
return json.load(f)
39+
content = f.read()
40+
41+
# Replace API key placeholders with environment variables
42+
jp_api_key = os.environ.get('JP_API_KEY', '')
43+
jp_challenge_api_key = os.environ.get('JP_CHALLENGE_API_KEY', '')
44+
45+
content = content.replace('{{{JP_API_KEY}}}', jp_api_key)
46+
content = content.replace('{{{JP_CHALLENGE_API_KEY}}}', jp_challenge_api_key)
47+
48+
return json.loads(content)
3949
except FileNotFoundError:
4050
print(f"{Colors.RED}Error: {file_path} not found{Colors.RESET}")
4151
sys.exit(1)

.github/workflows/deploy.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
uses: actions/checkout@v6
2828

2929
- name: Check Realtime feeds
30+
env:
31+
JP_API_KEY: ${{ secrets.JP_API_KEY }}
32+
JP_CHALLENGE_API_KEY: ${{ secrets.JP_CHALLENGE_API_KEY }}
3033
run: python .github/scripts/check_realtime_feeds.py
3134

3235
deploy:
@@ -37,6 +40,14 @@ jobs:
3740
- name: Checkout repository
3841
uses: actions/checkout@v6
3942

43+
- name: Replace API keys in realtime.json
44+
env:
45+
JP_API_KEY: ${{ secrets.JP_API_KEY }}
46+
JP_CHALLENGE_API_KEY: ${{ secrets.JP_CHALLENGE_API_KEY }}
47+
run: |
48+
sed -i "s/{{{JP_API_KEY}}}/$JP_API_KEY/g" realtime.json
49+
sed -i "s/{{{JP_CHALLENGE_API_KEY}}}/$JP_CHALLENGE_API_KEY/g" realtime.json
50+
4051
- name: Set up SSH key
4152
uses: webfactory/ssh-agent@v0.9.0
4253
with:

0 commit comments

Comments
 (0)