|
| 1 | +name: Translate |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + debug_enabled: |
| 7 | + type: boolean |
| 8 | + description: 'With TMATE' |
| 9 | + required: false |
| 10 | + default: false |
| 11 | + |
| 12 | + push: |
| 13 | + branches: [ "*" ] |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + - name: If Template exit |
| 21 | + shell: bash |
| 22 | + run: | |
| 23 | + cancel () { |
| 24 | + echo "Pacote de template, não precisa traduzir e compilar" |
| 25 | + echo "SAINDO...." |
| 26 | + curl -s -H "Authorization: token ${{ github.token }}" \ |
| 27 | + -X POST "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel" |
| 28 | + sleep infinity |
| 29 | + } |
| 30 | + if [ -n "$(grep biglinux-package-template pkgbuild/PKGBUILD)" ];then |
| 31 | + cancel |
| 32 | + fi |
| 33 | + |
| 34 | + - name: Install Translator Dependencies |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + sudo apt-get update |
| 38 | + sudo apt-get install \ |
| 39 | + git \ |
| 40 | + gettext \ |
| 41 | + npm |
| 42 | + # Install attranslator |
| 43 | + sudo npm install --location=global attranslate |
| 44 | +
|
| 45 | + ## Tmate ## |
| 46 | + - name: Setup TMATE Session |
| 47 | + uses: mxschmitt/action-tmate@v3 |
| 48 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} |
| 49 | + |
| 50 | + - name: Translate Package |
| 51 | + shell: bash #-O extglob {0} |
| 52 | + env: |
| 53 | + AZURE_KEY: ${{ secrets.AZURE_KEY }} |
| 54 | + OPENAI_KEY: ${{ secrets.OPENAI_KEY }} |
| 55 | + run: | |
| 56 | + cd .. |
| 57 | + git clone https://github.com/biglinux/big-auto-translator.git |
| 58 | + mv big-auto-translator/gettext_po_generator_github.sh . |
| 59 | + sudo cp -f big-auto-translator/openai-translate.js /usr/local/lib/node_modules/attranslate/dist/services/openai-translate.js |
| 60 | + gitfolder=$(echo ${{ github.repository }} | rev | cut -d "/" -f1 | rev) |
| 61 | + # export OriginalLang=en-US |
| 62 | + bash gettext_po_generator_github.sh $gitfolder |
| 63 | +
|
| 64 | + - name: Update github |
| 65 | + run: | |
| 66 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 67 | + git config --local user.name "github-actions[bot]" |
| 68 | + git add --all |
| 69 | + if [ -n "$(git commit -m "translate $(date +%y-%m-%d_%H:%M)" -a | grep "nothing to commit")" ];then exit 0; fi |
| 70 | +
|
| 71 | + - name: Push changes |
| 72 | + uses: ad-m/github-push-action@master |
| 73 | + with: |
| 74 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + branch: ${{ github.ref }} |
0 commit comments