Skip to content

Commit

Permalink
Try fix using enviroments in github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
panther7 committed Aug 30, 2022
1 parent 0bbaf86 commit d15eca5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/lang-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ jobs:
main:
runs-on: windows-latest
env:
TOLGEE_KEY: '${{ secrets.TOLGEE_TOKEN }}'
GIT_KEY: '${{ secrets.GIT_TOKEN }}'
TOLGEE_KEY: '${{ secrets.TOLGEE_TOKEN }}'
steps:
- uses: actions/checkout@v3

This comment has been minimized.

Copy link
@marticliment

marticliment Aug 31, 2022

Owner

This does not work since branch protection is enabled.

This comment has been minimized.

Copy link
@panther7

panther7 Aug 31, 2022

Author Contributor

Ok, then pull request is "only" best solution, like dependencies update (example: electron-userland/electron-builder#7036)

This comment has been minimized.

Copy link
@marticliment

marticliment Aug 31, 2022

Owner

Yep

- name: Download tolgee translations
run: |
mkdir tempfolder
cd tempfolder/
git clone https://${Env:GIT_KEY}@github.com/martinet101/ElevenClock/
cd ElevenClock/elevenclock/lang
cd elevenclock/lang
git config user.name "Tolgee bot"
git config user.email "noemail@github.com"
python download_translations.py --autocommit
Expand Down
37 changes: 10 additions & 27 deletions elevenclock/lang/download_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@
print(sys.argv[1])

try:
if(isAutoCommit):
apikey = os.environ["TOLGEE_KEY"]
else:
apikey = open("APIKEY.txt", "r").read()
print(" API key found in APIKEY.txt")
apikey = open("APIKEY.txt", "r").read()
print(" API key found in APIKEY.txt")
except FileNotFoundError:
if (isAutoCommit):
print(" Error: APIKEY.txt missing")
exit(1)
else:
apikey = os.environ.get("TOLGEE_KEY", "")
if (apikey == ""):
apikey = input("Write api key and press enter: ")

apiurl = f"https://app.tolgee.io/v2/projects/688/export?format=JSON&splitByScope=false&splitByScopeDelimiter=~&splitByScopeDepth=0&filterState=UNTRANSLATED&filterState=TRANSLATED&filterState=REVIEWED&zip=true&ak={apikey}"
Expand All @@ -45,36 +40,26 @@
print()
print(" Downloading updated translations...")


zipcontent = requests.get(apiurl)
f = open("langs.zip", "wb")
f.write(zipcontent.content)
fname = f.name
langArchiveName = f.name
f.close()
print(" Download complete!")
print()

downloadedLanguages = []

#olddir = "lang_backup"+str(int(time.time()))
#os.mkdir(olddir)
#for file in glob.glob('lang_*.json'):
# os.remove(file)
# shutil.move(file, olddir)

#print(f" Backup complete. The old files were moved to {olddir}")
#print()
print(" Download complete!")
print()
print("-------------------------------------------------------")
print()
print(" Extracting language files...")


print("size of langs.zip:", os.path.getsize(fname))

zip_file = zipfile.ZipFile(fname)

for file in glob.glob('lang_*.json'):
os.remove(file)

downloadedLanguages = []
zip_file = zipfile.ZipFile(langArchiveName)
for name in zip_file.namelist():
lang = os.path.splitext(name)[0]
if (lang in languageRemap):
Expand Down Expand Up @@ -138,7 +123,6 @@
f.close()



print(" Process complete!")
print()
print("-------------------------------------------------------")
Expand Down Expand Up @@ -176,4 +160,3 @@
os.system("git reset --hard") # prevent clean
else:
os.system("pause")

0 comments on commit d15eca5

Please sign in to comment.