Browse Source

#660 ensure we do not leak the Zenodo token

Rodja Trappe 2 năm trước cách đây
mục cha
commit
fae70064a2
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      .github/workflows/update_citation.py

+ 8 - 2
.github/workflows/update_citation.py

@@ -1,3 +1,4 @@
+import sys
 import yaml
 import os
 from datetime import datetime
@@ -14,8 +15,13 @@ def get_infos() -> str:
         'access_token': os.environ['ZENODO_TOKEN'],
         'q': 'nicegui', 'sort': 'mostrecent', 'status': 'published'
     }
-    response = requests.get('https://zenodo.org/api/records', params=params, headers=headers)
-    response.raise_for_status()
+    try:
+        response = requests.get('https://zenodo.org/api/records', params=params, headers=headers)
+        response.raise_for_status()
+    # Hide all error details to avoid leaking the token
+    except Exception:
+        print('Error while getting the Zenodo infos')
+        sys.exit(1)
     data = response.json()[0]['metadata']
     return data['doi'], data['version'], data['publication_date']