|
| 1 | +name: Generate Readme Translations |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - "1222--README-ci-auto-translation" |
| 6 | + |
| 7 | +jobs: |
| 8 | + translation: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + language: [ |
| 13 | + {code: 'CN', name: 'Chinese'}, |
| 14 | + {code: 'DE', name: 'German'}, |
| 15 | + {code: 'ES', name: 'Spanish'}, |
| 16 | + {code: 'FR', name: 'French'}, |
| 17 | + {code: 'HE', name: 'Hebrew'}, |
| 18 | + {code: 'IT', name: 'Italian'}, |
| 19 | + {code: 'JA', name: 'Japanese'}, |
| 20 | + {code: 'KOR', name: 'Korean'}, |
| 21 | + {code: 'PTBR', name: 'Portuguese (Brazil)'}, |
| 22 | + {code: 'RU', name: 'Russian'}, |
| 23 | + {code: 'TH', name: 'Thai'}, |
| 24 | + {code: 'TR', name: 'Turkish'}, |
| 25 | + {code: 'VI', name: 'Vietnamese'} |
| 26 | + ] |
| 27 | + permissions: |
| 28 | + contents: write |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + ref: main |
| 33 | + token: ${{ secrets.GH_TOKEN }} |
| 34 | + |
| 35 | + - name: Translate to ${{ matrix.language.name }} |
| 36 | + uses: 0xjord4n/aixion@v1.2.1 |
| 37 | + id: aixion |
| 38 | + with: |
| 39 | + config: > |
| 40 | + { |
| 41 | + "provider": "openai", |
| 42 | + "provider_options": { |
| 43 | + "api_key": "${{ secrets.OPENAI_API_KEY }}" |
| 44 | + }, |
| 45 | + "messages": [ |
| 46 | + { |
| 47 | + "role": "system", |
| 48 | + "content": "You will be provided with a markdown file in English, and your task is to translate it into ${{ matrix.language.name }}." |
| 49 | + }, |
| 50 | + { |
| 51 | + "role": "user", |
| 52 | + "content_path": "README.md" |
| 53 | + } |
| 54 | + ], |
| 55 | + "save_path": "README_${{ matrix.language.code }}.md", |
| 56 | + "model": "gpt-4o" |
| 57 | + } |
| 58 | +
|
| 59 | + # Upload each translated file as an artifact |
| 60 | + - name: Upload translation |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: readme-${{ matrix.language.code }} |
| 64 | + path: README_${{ matrix.language.code }}.md |
| 65 | + |
| 66 | + commit: |
| 67 | + needs: translation |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + with: |
| 72 | + ref: main |
| 73 | + token: ${{ secrets.GH_TOKEN }} |
| 74 | + |
| 75 | + # Download all translation artifacts |
| 76 | + - name: Download all translations |
| 77 | + uses: actions/download-artifact@v4 |
| 78 | + with: |
| 79 | + pattern: readme-* |
| 80 | + merge-multiple: true |
| 81 | + |
| 82 | + - name: Commit all translations |
| 83 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 84 | + with: |
| 85 | + commit_message: "chore: update all README translations" |
| 86 | + branch: main |
| 87 | + file_pattern: "README_*.md" |
| 88 | + commit_author: "GitHub Action <actions@github.com>" |
0 commit comments