Skip to content

Commit

Permalink
fix: pass GOOGLE_CREDENTIALS envvar as base64 encoded string
Browse files Browse the repository at this point in the history
as otherwise Github Action transforms the JSON.
And also add BATCH_JOB_KEY to .env during deployment.
  • Loading branch information
raphael0202 committed Sep 11, 2024
1 parent 3897d65 commit 6be2367
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/container-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ jobs:
# Google Cloud credentials
echo "GOOGLE_CREDENTIALS=${{ secrets.GOOGLE_CREDENTIALS }}" >> .env
# Secret key to secure batch job import
echo "BATCH_JOB_KEY=${{ secrets.BATCH_JOB_KEY }}" >> .env
- name: Create Docker volumes
uses: appleboy/ssh-action@master
Expand Down
4 changes: 3 additions & 1 deletion robotoff/batch/launch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import base64
import datetime
import json
import os
Expand All @@ -24,7 +25,8 @@ def check_google_credentials() -> None:
credentials_path,
)
credentials_path.parent.mkdir(parents=True, exist_ok=True)
credentials = json.loads(os.environ["GOOGLE_CREDENTIALS"])
credentials_base64 = os.environ["GOOGLE_CREDENTIALS"]
credentials = json.loads(base64.b64decode(credentials_base64).decode("utf-8"))
with open(credentials_path, "w") as f:
json.dump(credentials, f, indent=4)

Expand Down

0 comments on commit 6be2367

Please sign in to comment.