Skip to content

Commit

Permalink
fix: 🐛 Fixing github actions bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
YeyoM committed Jul 6, 2024
1 parent 57af500 commit 98dbd65
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/run_tests_and_upload_to_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
run: |
python -m unittest discover -s tests -p "test_*.py"
- name: Debug Environment Variables
run: |
echo "FIREBASE_TYPE: ${{ env.FIREBASE_TYPE }}"
echo "FIREBASE_PROJECT_ID: ${{ env.FIREBASE_PROJECT_ID }}"
- name: Check test status and run scraper/Firebase uploader
if: ${{ steps.test.outcome == 'success' }}
run: |
Expand Down
56 changes: 24 additions & 32 deletions src/firebase_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,30 @@ def initialize_firebase():
dotenv_path = find_dotenv()
load_dotenv(dotenv_path)

FIREBASE_URL = os.getenv("FIREBASE_URL")
FIREBASE_KEY = os.getenv("FIREBASE_KEY")
FIREBASE_TYPE = os.getenv("FIREBASE_TYPE")
FIREBASE_PROJECT_ID = os.getenv("FIREBASE_PROJECT_ID")
FIREBASE_PRIVATE_KEY_ID = os.getenv("FIREBASE_PRIVATE_KEY_ID")
FIREBASE_PRIVATE_KEY = os.getenv("FIREBASE_PRIVATE_KEY")
FIREBASE_CLIENT_EMAIL = os.getenv("FIREBASE_CLIENT_EMAIL")
FIREBASE_CLIENT_ID = os.getenv("FIREBASE_CLIENT_ID")
FIREBASE_AUTH_URI = os.getenv("FIREBASE_AUTH_URI")
FIREBASE_TOKEN_URI = os.getenv("FIREBASE_TOKEN_URI")
FIREBASE_AUTH_PROVIDER_X509_CERT_URL = os.getenv(
"FIREBASE_AUTH_PROVIDER_X509_CERT_URL"
)
FIREBASE_CLIENT_X509_CERT_URL = os.getenv("FIREBASE_CLIENT_X509_CERT_URL")
FIREBASE_UNIVERSE_DOMAIN = os.getenv("FIREBASE_UNIVERSE_DOMAIN")

cred = credentials.Certificate(
{
"type": FIREBASE_TYPE,
"project_id": FIREBASE_PROJECT_ID,
"private_key_id": FIREBASE_PRIVATE_KEY_ID,
"private_key": FIREBASE_PRIVATE_KEY,
"client_email": FIREBASE_CLIENT_EMAIL,
"client_id": FIREBASE_CLIENT_ID,
"auth_uri": FIREBASE_AUTH_URI,
"token_uri": FIREBASE_TOKEN_URI,
"auth_provider_x509_cert_url": FIREBASE_AUTH_PROVIDER_X509_CERT_URL,
"client_x509_cert_url": FIREBASE_CLIENT_X509_CERT_URL,
"universe_domain": FIREBASE_UNIVERSE_DOMAIN,
}
)
firebase_admin.initialize_app(cred, {"databaseURL": FIREBASE_URL})
# Parse the credentials as JSON
cred_dict = {
"type": os.getenv("FIREBASE_TYPE"),
"project_id": os.getenv("FIREBASE_PROJECT_ID"),
"private_key_id": os.getenv("FIREBASE_PRIVATE_KEY_ID"),
"private_key": os.getenv("FIREBASE_PRIVATE_KEY").replace(
"\\n", "\n"
), # Replace \\n with actual newlines
"client_email": os.getenv("FIREBASE_CLIENT_EMAIL"),
"client_id": os.getenv("FIREBASE_CLIENT_ID"),
"auth_uri": os.getenv("FIREBASE_AUTH_URI"),
"token_uri": os.getenv("FIREBASE_TOKEN_URI"),
"auth_provider_x509_cert_url": os.getenv(
"FIREBASE_AUTH_PROVIDER_X509_CERT_URL"
),
"client_x509_cert_url": os.getenv("FIREBASE_CLIENT_X509_CERT_URL"),
"universe_domain": os.getenv("FIREBASE_UNIVERSE_DOMAIN"),
}

# Remove any None values
cred_dict = {k: v for k, v in cred_dict.items() if v is not None}

cred = credentials.Certificate(cred_dict)
firebase_admin.initialize_app(cred, {"databaseURL": os.getenv("FIREBASE_URL")})


def backup_songs(songs_ref, backup_ref):
Expand Down

0 comments on commit 98dbd65

Please sign in to comment.