mirror of
				https://github.com/HackTricks-wiki/hacktricks.git
				synced 2025-10-10 18:36:50 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			101 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
name: Translator to JA (Japanese)
 | 
						|
 | 
						|
on:
 | 
						|
  push:
 | 
						|
    branches:
 | 
						|
      - master
 | 
						|
    paths-ignore:
 | 
						|
      - 'scripts/**'
 | 
						|
      - '.gitignore'
 | 
						|
      - '.github/**'
 | 
						|
      - Dockerfile
 | 
						|
  workflow_dispatch:
 | 
						|
 | 
						|
concurrency: ja
 | 
						|
 | 
						|
permissions:
 | 
						|
  packages: write
 | 
						|
  id-token: write
 | 
						|
  contents: write
 | 
						|
 | 
						|
jobs:
 | 
						|
  run-translation:
 | 
						|
    runs-on: ubuntu-latest
 | 
						|
    container:
 | 
						|
      image: ghcr.io/hacktricks-wiki/hacktricks-cloud/translator-image:latest
 | 
						|
    environment: prod
 | 
						|
    env:
 | 
						|
      LANGUAGE: Japanese
 | 
						|
      BRANCH: ja
 | 
						|
    
 | 
						|
    steps:
 | 
						|
      - name: Checkout code
 | 
						|
        uses: actions/checkout@v2
 | 
						|
        with:
 | 
						|
          fetch-depth: 0
 | 
						|
      
 | 
						|
      - name: Download language branch
 | 
						|
        run: |
 | 
						|
          git config --global --add safe.directory /__w/hacktricks/hacktricks
 | 
						|
          git config --global user.name 'Translator'
 | 
						|
          git config --global user.email 'github-actions@github.com'
 | 
						|
          git config pull.rebase false
 | 
						|
          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: 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
 | 
						|
            fi
 | 
						|
          done
 | 
						|
          python scripts/translator.py --language "$LANGUAGE" --branch "$BRANCH" --api-key "$OPENAI_API_KEY" -f "$(cat /tmp/file_paths.txt)" -t 3
 | 
						|
 | 
						|
      - name: Build mdBook
 | 
						|
        run: |
 | 
						|
          git checkout "$BRANCH"
 | 
						|
          git pull
 | 
						|
          MDBOOK_BOOK__LANGUAGE=$BRANCH mdbook build || (echo "Error logs" && cat hacktricks-preprocessor-error.log && echo "" && echo "" && echo "Debug logs" && (cat hacktricks-preprocessor.log | tail -n 20) && exit 1)
 | 
						|
      
 | 
						|
      - name: Update searchindex.js in repo
 | 
						|
        run: |
 | 
						|
          git checkout $BRANCH
 | 
						|
          git pull
 | 
						|
          if [ -f "book/searchindex.js" ]; then
 | 
						|
            cp book/searchindex.js searchindex.js
 | 
						|
          fi
 | 
						|
          (git add searchindex.js;
 | 
						|
          git commit -m "Update searchindex";
 | 
						|
          git push) || echo "No changes to searchindex.js"
 | 
						|
      
 | 
						|
      # Login in AWs
 | 
						|
      - name: Configure AWS credentials using OIDC
 | 
						|
        uses: aws-actions/configure-aws-credentials@v3
 | 
						|
        with:
 | 
						|
          role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
 | 
						|
          aws-region: us-east-1
 | 
						|
      
 | 
						|
      # Sync the build to S3
 | 
						|
      - name: Sync to S3
 | 
						|
        run: |
 | 
						|
          echo "Current branch:"
 | 
						|
          git rev-parse --abbrev-ref HEAD
 | 
						|
          echo "Syncing $BRANCH to S3"
 | 
						|
          aws s3 sync ./book s3://hacktricks-wiki/$BRANCH --delete
 | 
						|
          echo "Sync completed"
 | 
						|
          echo "Cat 3 files from the book"
 | 
						|
          find . -type f -name 'index.html' -print | head -n 3 | xargs -r cat
 |