|
| 1 | +name:Pull Translations from Transifex |
| 2 | + |
| 3 | +on: |
| 4 | +schedule: |
| 5 | + -cron:'0 0 * * *' |
| 6 | +workflow_dispatch: |
| 7 | +permissions: |
| 8 | +contents:write |
| 9 | + |
| 10 | +jobs: |
| 11 | +update-translation: |
| 12 | +runs-on:ubuntu-latest |
| 13 | +strategy: |
| 14 | +fail-fast:false |
| 15 | +matrix: |
| 16 | +version:[ '3.14' ] |
| 17 | +steps: |
| 18 | + -uses:styfle/cancel-workflow-action@main |
| 19 | +with: |
| 20 | +access_token:${{ secrets.GITHUB_TOKEN }} |
| 21 | + -uses:actions/setup-python@master |
| 22 | +with: |
| 23 | +python-version:3 |
| 24 | + -name:Install Dependencies |
| 25 | +run:| |
| 26 | + sudo apt-get install -y gettext |
| 27 | + pip install requests cogapp polib transifex-python sphinx-intl blurb six |
| 28 | + curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash |
| 29 | +working-directory:/usr/local/bin |
| 30 | + -uses:actions/checkout@master |
| 31 | +with: |
| 32 | +ref:${{ matrix.version }} |
| 33 | +fetch-depth:0 |
| 34 | + -run:curl -O https://raw.githubusercontent.com/python-docs-translations/transifex-automations/master/sample-workflows/transifex-util.py |
| 35 | + -run:chmod +x transifex-util.py |
| 36 | + -run:./transifex-util.py recreate_tx_config --language sv --project-slug python-newest --version ${{ matrix.version }} |
| 37 | +env: |
| 38 | +TX_TOKEN:${{ secrets.TX_TOKEN }} |
| 39 | + -run:./transifex-util.py fetch --language sv --project-slug python-newest --version ${{ matrix.version }} |
| 40 | +env: |
| 41 | +TX_TOKEN:${{ secrets.TX_TOKEN }} |
| 42 | + -run:./transifex-util.py delete_obsolete_files --language sv --project-slug python-newest --version ${{ matrix.version }} |
| 43 | + -name:Set up Git |
| 44 | +run:| |
| 45 | + git config --local user.email github-actions@github.com |
| 46 | + git config --local user.name "GitHub Action's update-translation job" |
| 47 | + -name:Filter files |
| 48 | +run:| |
| 49 | + ! git diff -I'^"POT-Creation-Date: ' \ |
| 50 | + -I'^"Language-Team: ' \ |
| 51 | + -I'^# ' -I'^"Last-Translator: ' \ |
| 52 | + --exit-code \ |
| 53 | + && echo "SIGNIFICANT_CHANGES=1" >> $GITHUB_ENV || exit 0 |
| 54 | + -run:git add . |
| 55 | + -run:git commit -m 'Update translation from Transifex' |
| 56 | +if:env.SIGNIFICANT_CHANGES |
| 57 | + -uses:ad-m/github-push-action@master |
| 58 | +if:env.SIGNIFICANT_CHANGES |
| 59 | +with: |
| 60 | +branch:${{ matrix.version }} |
| 61 | +github_token:${{ secrets.GITHUB_TOKEN }} |