Stop Crowdin Daily Workflow from activating with empty API key (#13440)
* Stop Crowdin Daily Workflow from activating with empty API key * Make sure that the API key is always reset
This commit is contained in:
parent
c29fd8e53a
commit
c28df9ccef
|
@ -9,11 +9,17 @@ import urllib.request
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
# Check Crowdin API Key
|
# Check Crowdin API Key
|
||||||
if len(sys.argv) < 2:
|
|
||||||
print('Please provide Crowdin API Key!')
|
|
||||||
exit()
|
|
||||||
|
|
||||||
api_key = sys.argv[1]
|
try:
|
||||||
|
api_key = sys.argv[1] # IndexError, if no key is given
|
||||||
|
if not api_key: # if key is empty
|
||||||
|
raise ValueError
|
||||||
|
except IndexError:
|
||||||
|
print('Please provide Crowdin API Key!')
|
||||||
|
raise
|
||||||
|
except ValueError:
|
||||||
|
print("Crowdin API Key can't be empty!")
|
||||||
|
raise
|
||||||
|
|
||||||
# Apply Crowdin API Key
|
# Apply Crowdin API Key
|
||||||
crowdin_config_file = open('crowdin.yaml', 'r')
|
crowdin_config_file = open('crowdin.yaml', 'r')
|
||||||
|
@ -24,6 +30,7 @@ crowdin_config_file = open('crowdin.yaml', 'w')
|
||||||
crowdin_config_file.write(crowdin_config)
|
crowdin_config_file.write(crowdin_config)
|
||||||
crowdin_config_file.close()
|
crowdin_config_file.close()
|
||||||
|
|
||||||
|
try: # catch any exception after crowdin.yaml was changed
|
||||||
# Download Crowdin CLI
|
# Download Crowdin CLI
|
||||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
@ -75,3 +82,13 @@ crowdin_config = crowdin_config.replace(api_key, '_secret_')
|
||||||
crowdin_config_file = open('crowdin.yaml', 'w')
|
crowdin_config_file = open('crowdin.yaml', 'w')
|
||||||
crowdin_config_file.write(crowdin_config)
|
crowdin_config_file.write(crowdin_config)
|
||||||
crowdin_config_file.close()
|
crowdin_config_file.close()
|
||||||
|
except:
|
||||||
|
# Reset Crowdin API Key no matter what
|
||||||
|
crowdin_config_file = open('crowdin.yaml', 'r')
|
||||||
|
crowdin_config = crowdin_config_file.read()
|
||||||
|
crowdin_config_file.close()
|
||||||
|
crowdin_config = crowdin_config.replace(api_key, '_secret_')
|
||||||
|
crowdin_config_file = open('crowdin.yaml', 'w')
|
||||||
|
crowdin_config_file.write(crowdin_config)
|
||||||
|
crowdin_config_file.close()
|
||||||
|
raise
|
||||||
|
|
Loading…
Reference in New Issue