From 78775e07370b5428020c514e60e603d05011dc19 Mon Sep 17 00:00:00 2001 From: carlospolop Date: Thu, 21 Aug 2025 00:24:29 +0200 Subject: [PATCH] f --- .github/workflows/translate_es.yml | 41 ++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/translate_es.yml b/.github/workflows/translate_es.yml index 30c398a3d..69e37c6f9 100644 --- a/.github/workflows/translate_es.yml +++ b/.github/workflows/translate_es.yml @@ -34,6 +34,21 @@ jobs: with: fetch-depth: 0 + - name: Update and download scripts + run: | + sudo apt-get update + sudo apt-get install wget -y + mkdir scripts + cd scripts + wget -O get_and_save_refs.py https://raw.githubusercontent.com/carlospolop/hacktricks-cloud/master/scripts/get_and_save_refs.py + wget -O compare_and_fix_refs.py https://raw.githubusercontent.com/carlospolop/hacktricks-cloud/master/scripts/compare_and_fix_refs.py + wget -O translator.py https://raw.githubusercontent.com/carlospolop/hacktricks-cloud/master/scripts/translator.py + cd .. + + - name: Run get_and_save_refs.py + run: | + python scripts/get_and_save_refs.py + - name: Download language branch run: | git config --global --add safe.directory /__w/hacktricks/hacktricks @@ -43,26 +58,30 @@ jobs: git checkout $BRANCH git pull git checkout master - - - name: Update & install translator.py (if needed) - run: | - sudo apt-get update - sudo apt-get install wget -y - mkdir scripts - cd scripts - wget https://raw.githubusercontent.com/carlospolop/hacktricks-cloud/master/scripts/translator.py - cd .. + - name: Update the refs from master to language branch + run: | + python scripts/compare_and_fix_refs.py --files-unmatched-paths /tmp/file_paths.txt - name: Run translation script on changed files run: | export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} git diff --name-only HEAD~1 | grep -v "SUMMARY.md" | while read -r file; do if echo "$file" | grep -qE '\.md$'; then - echo -n "$file , " >> /tmp/file_paths.txt + echo -n ",$file" >> /tmp/file_paths.txt fi done - python scripts/translator.py --language "$LANGUAGE" --branch "$BRANCH" --api-key "$OPENAI_API_KEY" -f "$(cat /tmp/file_paths.txt)" -t 3 + + if [ -s /tmp/file_paths.txt ]; then + python scripts/translator.py \ + --language "$LANGUAGE" \ + --branch "$BRANCH" \ + --api-key "$OPENAI_API_KEY" \ + -f "$(cat /tmp/file_paths.txt)" \ + -t 3 + else + echo "No markdown files changed, skipping translation." + fi - name: Build mdBook run: |