[Tradução] Lote com 193 sugestão(Ôes) #54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Apply Translation Suggestions | |
| on: | |
| issues: | |
| types: [labeled] | |
| # ========== FILA AUTOMĂTICA ========== | |
| # Quando vĂĄrias issues sĂŁo aprovadas rapidamente, os workflows | |
| # entram numa fila e sĂŁo executados em sequĂȘncia (nĂŁo em paralelo) | |
| concurrency: | |
| group: apply-translations-queue | |
| cancel-in-progress: false # Espera o anterior terminar, NĂO cancela | |
| jobs: | |
| apply-translations: | |
| # SĂł executa quando a label "approved" Ă© adicionada | |
| if: github.event.label.name == 'approved' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| steps: | |
| # Checkout do repositório de traduçÔes (wwm_brasileiro_auto_path) | |
| - name: Checkout translation repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: rodrigomiquilino/wwm_brasileiro_auto_path | |
| ref: dev | |
| token: ${{ secrets.TRANSLATION_PAT }} | |
| path: translation-repo | |
| # Checkout do repositĂłrio principal (para o script Python) | |
| - name: Checkout main repository | |
| uses: actions/checkout@v4 | |
| with: | |
| path: main-repo | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Extract and Apply Translations | |
| id: apply | |
| env: | |
| ISSUE_BODY: ${{ github.event.issue.body }} | |
| ISSUE_NUMBER: ${{ github.event.issue.number }} | |
| ISSUE_AUTHOR: ${{ github.event.issue.user.login }} | |
| TARGET_REPO_PATH: translation-repo | |
| run: | | |
| python main-repo/.github/scripts/apply_translations.py | |
| - name: Commit Changes | |
| if: steps.apply.outputs.changes_made == 'true' | |
| working-directory: translation-repo | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add pt-br.tsv | |
| git commit -m "feat(translation): aplicar sugestÔes da Issue #${{ github.event.issue.number }} | |
| Contribuição de @${{ github.event.issue.user.login }} | |
| Co-authored-by: ${{ github.event.issue.user.login }} <${{ github.event.issue.user.id }}+${{ github.event.issue.user.login }}@users.noreply.github.com>" | |
| # ========== PUSH COM RETRY ========== | |
| # Sincroniza antes do push e tenta 3x com backoff exponencial | |
| for attempt in 1 2 3; do | |
| echo "đ€ Tentativa $attempt de push..." | |
| git pull --rebase origin dev 2>/dev/null || true | |
| if git push origin dev; then | |
| echo "â Push realizado com sucesso!" | |
| break | |
| else | |
| if [ $attempt -lt 3 ]; then | |
| echo "â ïž Falha no push, aguardando $((attempt * 2))s..." | |
| sleep $((attempt * 2)) | |
| else | |
| echo "â Falha apĂłs 3 tentativas" | |
| exit 1 | |
| fi | |
| fi | |
| done | |
| - name: Close Issue with Success | |
| if: steps.apply.outputs.changes_made == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const applied = process.env.APPLIED_COUNT || '0'; | |
| const skipped = process.env.SKIPPED_COUNT || '0'; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `## â TraduçÔes Aplicadas com Sucesso! | |
| **Resultado:** | |
| - â Aplicadas: ${applied} tradução(Ă”es) | |
| - âïž Ignoradas: ${skipped} (jĂĄ existentes ou invĂĄlidas) | |
| Obrigado pela contribuição, @${context.payload.issue.user.login}! đ | |
| As alteraçÔes foram aplicadas na branch \`dev\` do repositório de traduçÔes.` | |
| }); | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| state: 'closed', | |
| labels: ['translation', 'applied'] | |
| }); | |
| env: | |
| APPLIED_COUNT: ${{ steps.apply.outputs.applied_count }} | |
| SKIPPED_COUNT: ${{ steps.apply.outputs.skipped_count }} | |
| - name: Comment on Failure | |
| if: failure() || steps.apply.outputs.changes_made == 'false' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const errorMsg = process.env.ERROR_MESSAGE || 'Erro desconhecido'; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `## â ïž NĂŁo foi possĂvel aplicar as traduçÔes | |
| **Motivo:** ${errorMsg} | |
| Por favor, verifique se o formato da Issue estĂĄ correto e tente novamente. | |
| Se o problema persistir, aplique as traduçÔes manualmente.` | |
| }); | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| name: 'approved' | |
| }); | |
| env: | |
| ERROR_MESSAGE: ${{ steps.apply.outputs.error_message }} |