88 - ' scripts/**'
99 - ' .gitignore'
1010 - ' .github/**'
11+ - Dockerfile
1112 workflow_dispatch :
1213
1314concurrency : af
@@ -19,93 +20,51 @@ permissions:
1920jobs :
2021 run-translation :
2122 runs-on : ubuntu-latest
22- environment : prod
23- env :
24- LANGUAGE : Afrikaans
25- BRANCH : af
26-
23+ container :
24+ # Use the image you pushed to GHCR
25+ image : ghcr.io/HackTricks-wiki/hacktricks-cloud/translator-image:latest
26+
2727 steps :
2828 - name : Checkout code
2929 uses : actions/checkout@v2
3030 with :
31- fetch-depth : 0 # Needed to download everything to be able to access the master & language branches
32-
33- - name : Set up Python
34- uses : actions/setup-python@v2
35- with :
36- python-version : 3.12
37-
38- - name : Install python dependencies
39- run : |
40- python -m pip install --upgrade pip
41- pip3 install openai tqdm tiktoken
42-
43- # Install Rust and Cargo
44- - name : Install Rust and Cargo
45- uses : actions-rs/toolchain@v1
46- with :
47- toolchain : stable
48- override : true
49-
50- # Install mdBook and Plugins
51- - name : Install mdBook and Plugins
52- run : |
53- cargo install mdbook
54- cargo install mdbook-alerts
55- cargo install mdbook-reading-time
56- cargo install mdbook-pagetoc
57- cargo install mdbook-tabs
58- cargo install mdbook-codename
59-
31+ fetch-depth : 0
6032
61- - name : Update & install wget & translator.py
33+ - name : Update & install translator.py (if needed)
6234 run : |
63- sudo apt-get update
64- sudo apt-get install wget -y
6535 cd scripts
6636 rm -f translator.py
6737 wget https://raw.githubusercontent.com/carlospolop/hacktricks-cloud/master/scripts/translator.py
6838 cd ..
69-
70- - name : Download language branch # Make sure we have last version
39+
40+ - name : Download language branch
7141 run : |
7242 git config --global user.name 'Translator'
7343 git config --global user.email '[email protected] ' 74- git checkout "$BRANCH"
44+ git checkout af
7545 git pull
7646 git checkout master
7747
7848 - name : Run translation script on changed files
7949 run : |
80- echo "Starting translations"
81- echo "Commit: $GITHUB_SHA"
82-
83- # Export the OpenAI API key as an environment variable
8450 export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
85-
86- # Run the translation script on each changed file
8751 git diff --name-only HEAD~1 | grep -v "SUMMARY.md" | while read -r file; do
8852 if echo "$file" | grep -qE '\.md$'; then
8953 echo -n "$file , " >> /tmp/file_paths.txt
90- else
91- echo "Skipping $file"
9254 fi
9355 done
56+ python scripts/translator.py --language "Afrikaans" --branch "af" --api-key "$OPENAI_API_KEY" -f "$(cat /tmp/file_paths.txt)" -t 3
9457
95- echo "Translating $(cat /tmp/file_paths.txt)"
96- python scripts/translator.py --language "$LANGUAGE" --branch "$BRANCH" --api-key "$OPENAI_API_KEY" -f "$(cat /tmp/file_paths.txt)" -t 3
97-
98- # Push changes to the repository
9958 - name : Commit and push changes
10059 run : |
101- git checkout "$BRANCH"
60+ git checkout af
10261 git add -A
103- git commit -m "Translated $BRANCH files" || true
104- git push --set-upstream origin "$BRANCH"
62+ git commit -m "Translated Afrikaans files" || true
63+ git push --set-upstream origin af
10564
106- # Build the mdBook
10765 - name : Build mdBook
108- run : MDBOOK_BOOK__LANGUAGE=$BRANCH mdbook build || (cat hacktricks-preprocessor-error.log && exit 1)
66+ run : |
67+ MDBOOK_BOOK__LANGUAGE=af mdbook build || (cat hacktricks-preprocessor-error.log && exit 1)
10968
11069 # Login in AWs
11170 - name : Configure AWS credentials using OIDC
0 commit comments