worflows
This commit is contained in:
parent
49fc1421aa
commit
b94077922e
53
.github/workflows/Add Hacktricks Support.yml
vendored
53
.github/workflows/Add Hacktricks Support.yml
vendored
@ -1,53 +0,0 @@
|
|||||||
|
|
||||||
name: Add Hacktricks Support
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
label:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# checkout
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
with:
|
|
||||||
ref: ${{ github.head_ref }}
|
|
||||||
|
|
||||||
- name: Run script file
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
exit #Dont run it
|
|
||||||
support_hacktricks_text='Cgo8ZGV0YWlscz4KCjxzdW1tYXJ5PjxzdHJvbmc+U3VwcG9ydCBIYWNrVHJpY2tzIGFuZCBnZXQgYmVuZWZpdHMhPC9zdHJvbmc+PC9zdW1tYXJ5PgoKRG8geW91IHdvcmsgaW4gYSAqKmN5YmVyc2VjdXJpdHkgY29tcGFueSoqPyBEbyB5b3Ugd2FudCB0byBzZWUgeW91ciAqKmNvbXBhbnkgYWR2ZXJ0aXNlZCBpbiBIYWNrVHJpY2tzKio/IG9yIGRvIHlvdSB3YW50IHRvIGhhdmUgYWNjZXNzIHRoZSAqKmxhdGVzdCB2ZXJzaW9uIG9mIHRoZSBQRUFTUyBvciBkb3dubG9hZCBIYWNrVHJpY2tzIGluIFBERioqPyBDaGVjayB0aGUgWyoqU1VCU0NSSVBUSU9OIFBMQU5TKipdKGh0dHBzOi8vZ2l0aHViLmNvbS9zcG9uc29ycy9jYXJsb3Nwb2xvcCkhCgpEaXNjb3ZlciBbKipUaGUgUEVBU1MgRmFtaWx5KipdKGh0dHBzOi8vb3BlbnNlYS5pby9jb2xsZWN0aW9uL3RoZS1wZWFzcy1mYW1pbHkpLCBvdXIgY29sbGVjdGlvbiBvZiBleGNsdXNpdmUgWyoqTkZUcyoqXShodHRwczovL29wZW5zZWEuaW8vY29sbGVjdGlvbi90aGUtcGVhc3MtZmFtaWx5KQoKR2V0IHRoZSBbKipvZmZpY2lhbCBQRUFTUyAmIEhhY2tUcmlja3Mgc3dhZyoqXShodHRwczovL3BlYXNzLmNyZWF0b3Itc3ByaW5nLmNvbSkKCioqSm9pbiB0aGUqKiBbKirwn5KsKipdKGh0dHBzOi8vZW1vamlwZWRpYS5vcmcvc3BlZWNoLWJhbGxvb24vKSBbKipEaXNjb3JkIGdyb3VwKipdKGh0dHBzOi8vZGlzY29yZC5nZy9oUmVwNFJVajdmKSBvciB0aGUgWyoqdGVsZWdyYW0gZ3JvdXAqKl0oaHR0cHM6Ly90Lm1lL3BlYXNzKSBvciAqKmZvbGxvdyoqIG1lIG9uICoqVHdpdHRlcioqIFsqKvCfkKYqKl0oaHR0cHM6Ly9naXRodWIuY29tL2Nhcmxvc3BvbG9wL2hhY2t0cmlja3MvdHJlZS83YWYxOGI2MmIzYmRjNDIzZTExNDQ0Njc3YTZhNzNkNDA0MzUxMWU5L1xbaHR0cHM6L2Vtb2ppcGVkaWEub3JnL2JpcmQvUkVBRE1FLm1kKVsqKkBjYXJsb3Nwb2xvcG0qKl0oaHR0cHM6Ly90d2l0dGVyLmNvbS9jYXJsb3Nwb2xvcG0pKiouKioKCioqU2hhcmUgeW91ciBoYWNraW5nIHRyaWNrcyBzdWJtaXR0aW5nIFBScyB0byB0aGUqKiBbKipoYWNrdHJpY2tzIGdpdGh1YiByZXBvKipdKGh0dHBzOi8vZ2l0aHViLmNvbS9jYXJsb3Nwb2xvcC9oYWNrdHJpY2tzKSoqLioqCgo8L2RldGFpbHM+CgoK'
|
|
||||||
|
|
||||||
|
|
||||||
for f in `find ./ -name "*.md" 2>/dev/null`; do
|
|
||||||
if grep -viq "support hacktricks" "$f"; then
|
|
||||||
echo "$f"
|
|
||||||
echo $support_hacktricks_text | base64 -d > temp
|
|
||||||
cat "$f" >> temp
|
|
||||||
echo $support_hacktricks_text | base64 -d >> temp
|
|
||||||
mv temp "$f"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
- name: Create local changes
|
|
||||||
run: |
|
|
||||||
git add .
|
|
||||||
|
|
||||||
#- name: Commit results to Github
|
|
||||||
# run: |
|
|
||||||
# git config --local user.email "autoad@hacktricks.com"
|
|
||||||
# git config --global user.name "autoad"
|
|
||||||
# git pull origin "${{ github.ref }}" --autostash --rebase -Xours
|
|
||||||
# git commit -m "Ad hacktricks sponsoring" -a --allow-empty
|
|
||||||
|
|
||||||
#- name: Push changes
|
|
||||||
# uses: ad-m/github-push-action@master
|
|
||||||
# with:
|
|
||||||
# branch: ${{ github.head_ref }}
|
|
||||||
# github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# force: true
|
|
||||||
|
|
81
.github/workflows/translate_es.yml
vendored
Normal file
81
.github/workflows/translate_es.yml
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
name: Translator to ES (Spanish)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths-ignore:
|
||||||
|
- 'scripts/**'
|
||||||
|
- '.gitignore'
|
||||||
|
- '.github/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-translation:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: prod
|
||||||
|
env:
|
||||||
|
LANGUAGE: Spanish
|
||||||
|
BRANCH: es
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 #Needed to download everything to be able to access the master & language branches
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.8
|
||||||
|
|
||||||
|
- name: Update & install wget & translator.py
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install wget -y
|
||||||
|
mkdir scripts
|
||||||
|
cd scripts
|
||||||
|
wget https://raw.githubusercontent.com/carlospolop/hacktricks-cloud/master/scripts/translator.py
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
- name: Install python dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip3 install openai tqdm
|
||||||
|
|
||||||
|
- name: Download language branch #Make sure we have last version
|
||||||
|
run: |
|
||||||
|
git config --global user.name 'Spanish Translator'
|
||||||
|
git config --global user.email 'github-actions@github.com'
|
||||||
|
git checkout "$BRANCH"
|
||||||
|
git pull
|
||||||
|
git checkout master
|
||||||
|
|
||||||
|
- name: Run translation script on changed files
|
||||||
|
run: |
|
||||||
|
# Start a subshell with a timeout (5h)
|
||||||
|
timeout 18000s bash << 'EOF'
|
||||||
|
echo "Starting translations"
|
||||||
|
echo "Commit: $GITHUB_SHA"
|
||||||
|
|
||||||
|
# Export the OpenAI API key as an environment variable
|
||||||
|
export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
|
||||||
|
|
||||||
|
# Run the translation script on each changed file
|
||||||
|
git diff-tree --no-commit-id --name-only -r "$GITHUB_SHA" | grep -v "SUMMARY.md" | while read -r file; do
|
||||||
|
if echo "$file" | grep -qE '\.md$'; then
|
||||||
|
echo "Translating $file"
|
||||||
|
python scripts/translator.py --language "$LANGUAGE" --branch "$BRANCH" --api-key "$OPENAI_API_KEY" --file-path "$file"
|
||||||
|
else
|
||||||
|
echo "Skipping $file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Commit and push changes
|
||||||
|
run: |
|
||||||
|
git checkout "$BRANCH"
|
||||||
|
git add -A
|
||||||
|
git commit -m "Translated $BRANCH files" || true
|
||||||
|
git push --set-upstream origin "$BRANCH"
|
Loading…
Reference in New Issue
Block a user