Skip to content

Commit

Permalink
try frozen build
Browse files Browse the repository at this point in the history
  • Loading branch information
mrf0rtuna4 committed May 3, 2024
1 parent 9924e9b commit 439f0af
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/translate-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GTK }}
LANGS: 'serbian,italian,english'
DIST: 'dist'

- name: Push to GitHub
uses: crazy-max/ghaction-github-pages@v3.1.0
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ COPY requirements.txt ./

COPY core core

RUN export YARN_CACHE_FOLDER="$(mktemp -d)"
RUN pip install -r requirements.txt

RUN yarn build:action
RUN yarn build

FROM python:3.8
WORKDIR /action-end

COPY --from=builder /app/core/dist/ /action-end/
RUN export YARN_CACHE_FOLDER="$(mktemp -d)"
COPY --from=builder /app/core/ /action-end/

CMD ["python", "core/translator"]
CMD ["python", "/core/translator"]
8 changes: 1 addition & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,4 @@ description: Generates localised readme files for your git
author: mrf0rtuna4
runs:
using: 'docker'
image: 'docker://python:3.8'
env:
DIST: ${{ inputs.dist }}
inputs:
dist:
description: 'Path to the dist directory'
required: true
image: 'docker://python:3.8'
10 changes: 5 additions & 5 deletions core/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def read_readme():
with open("core/README.md", "r", encoding="utf-8") as file:
with open("README.md", "r", encoding="utf-8") as file:
return file.read()


Expand All @@ -17,18 +17,18 @@ def update_localizations():
languages = [lang.strip() for lang in selected_langs.split(",")]
files = []

if not os.path.exists("core/dist"):
os.makedirs("core/dist")
if not os.path.exists("dist"):
os.makedirs("dist")

for lang in languages:
try:
translated_content = GoogleTranslator(
source='auto', target=lang).translate(text=no_links_content)

with open(f"core/dist/{lang}.md", "w", encoding="utf-8") as file:
with open(f"dist/{lang}.md", "w", encoding="utf-8") as file:
file.write(translated_content)
print(f"Localization for {lang} updated.")
files.append(f"core/dist/{lang}.md")
files.append(f"dist/{lang}.md")
except Exception as e:
print(f"Failed to translate to {lang}: {str(e)}")

Expand Down

0 comments on commit 439f0af

Please sign in to comment.