|
| 1 | +name:Update translations |
| 2 | + |
| 3 | +on: |
| 4 | +workflow_dispatch: |
| 5 | +push: |
| 6 | +paths: |
| 7 | + -'.github/workflows/update.yml' |
| 8 | + -'scripts/update.sh' |
| 9 | +branches: |
| 10 | + -'*' |
| 11 | + -'*/*' |
| 12 | + -'**' |
| 13 | + -'!3.?' |
| 14 | + -'!2.*' |
| 15 | +schedule: |
| 16 | + -cron:'0 23 * * *' |
| 17 | + |
| 18 | +env: |
| 19 | +CPYTHON_BRANCH:'3.10' |
| 20 | +LANGUAGE:'pt_BR' |
| 21 | + |
| 22 | +jobs: |
| 23 | +update: |
| 24 | +# Job to pull translation from Transifex platform, and commit & push changes |
| 25 | +runs-on:ubuntu-latest |
| 26 | +steps: |
| 27 | + -name:Check out ${{ github.repository }} |
| 28 | +uses:actions/checkout@v2 |
| 29 | + -name:Check out CPython |
| 30 | +uses:actions/checkout@v2 |
| 31 | +with: |
| 32 | +repository:python/cpython |
| 33 | +persist-credentials:false |
| 34 | +ref:${{ env.CPYTHON_BRANCH }} |
| 35 | +path:cpython |
| 36 | + -name:Set up Python 3.9 |
| 37 | +uses:actions/setup-python@v2 |
| 38 | +with: |
| 39 | +python-version:'3.9' |
| 40 | + -name:Install dependencies |
| 41 | +run:| |
| 42 | + sudo apt update -y && sudo apt install gettext -y |
| 43 | + pip3 install --upgrade pip |
| 44 | + pip3 install -r requirements.txt -r cpython/Doc/requirements.txt |
| 45 | + -name:Update translations |
| 46 | +run:| |
| 47 | + sh scripts/update.sh |
| 48 | +env: |
| 49 | +TX_TOKEN:${{ secrets.TX_TOKEN }} |
| 50 | +LANGUAGE:${{ env.LANGUAGE }} |
| 51 | + -name:Wrap catalog message files |
| 52 | +run:| |
| 53 | + powrap --modified |
| 54 | + -name:Commit and push changes |
| 55 | +if:github.repository == 'rffontenelle/python-docs-pt-br' |
| 56 | +run:| |
| 57 | + git config user.name github-actions |
| 58 | + git config user.email github-actions@github.com |
| 59 | + git status |
| 60 | + git add -A |
| 61 | + git diff-index --quiet HEAD || ( git commit -m "Update translations from Transifex" && git push ) |
| 62 | +
|
| 63 | +merge: |
| 64 | +# Merge translations previously updated into older branches to make sure |
| 65 | +# older versions of Python Docs gets translated as well. |
| 66 | +# 'overwrite=true' means strings previously translated will get overwritten; |
| 67 | +# other branches will preserve translated strings, only filling in new |
| 68 | +# translations. |
| 69 | +name:merge into ${{ matrix.branch }} |
| 70 | +needs:[update] |
| 71 | +strategy: |
| 72 | +matrix: |
| 73 | +branch:[ 3.9, 3.8, 3.7, 3.6, 2.7 ] |
| 74 | +include: |
| 75 | + -branch:3.9 |
| 76 | +overwrite:true |
| 77 | +runs-on:ubuntu-latest |
| 78 | +steps: |
| 79 | + -name:Get current branch name |
| 80 | +shell:bash |
| 81 | +run: |
| 82 | +echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV |
| 83 | + -name:Check out source branch (${{ env.CURRENT_BRANCH }}) |
| 84 | +uses:actions/checkout@v2 |
| 85 | +with: |
| 86 | +path:${{ env.CURRENT_BRANCH }} |
| 87 | +persist-credentials:false |
| 88 | + -name:Check out target branch (${{ matrix.branch }}) |
| 89 | +uses:actions/checkout@v2 |
| 90 | +with: |
| 91 | +ref:${{ matrix.branch }} |
| 92 | +path:${{ matrix.branch }} |
| 93 | + -name:Install dependencies |
| 94 | +run:| |
| 95 | + sudo apt update -y && sudo apt install gettext -y |
| 96 | + pip3 install pomerge powrap |
| 97 | + -name:Merge overwriting on stable release branch |
| 98 | +if:${{ matrix.overwrite == true }} |
| 99 | +run:| |
| 100 | + pomerge --from ${{ env.CURRENT_BRANCH }}/**/*.po --to ${{ matrix.branch }}/**/*.po |
| 101 | + -name:Merge without overwriting on EOL or security-fix release branch |
| 102 | +if:${{ matrix.overwrite != true }} |
| 103 | +run:| |
| 104 | + pomerge --no-overwrite --from ${{ env.CURRENT_BRANCH }}/**/*.po --to ${{ matrix.branch }}/**/*.po |
| 105 | + -name:Wrap catalog message files |
| 106 | +run:| |
| 107 | + powrap --modified -C ${{ matrix.branch }} |
| 108 | + -name:Commit and push changes |
| 109 | +if:github.repository == 'rffontenelle/python-docs-pt-br' |
| 110 | +run:| |
| 111 | + cd ${{ matrix.branch }} |
| 112 | + git config user.name github-actions |
| 113 | + git config user.email github-actions@github.com |
| 114 | + git status |
| 115 | + git add -A |
| 116 | + git diff-index --quiet HEAD || ( git commit -m "Merge ${{ env.CURRENT_BRANCH }} into ${{ matrix.branch }}" && git push ) |
| 117 | +
|
| 118 | +call-build: |
| 119 | +# Call the build workflow after updating |
| 120 | +name:call |
| 121 | +needs:[update] |
| 122 | +uses:rffontenelle/python-docs-pt-br/.github/workflows/build.yml@3.10 |
| 123 | +with: |
| 124 | +was-called:yes |
| 125 | +secrets: |
| 126 | +TELEGRAM_TO:${{ secrets.TELEGRAM_TO }} |
| 127 | +TELEGRAM_TOKEN:${{ secrets.TELEGRAM_TOKEN }} |
| 128 | + |
| 129 | +call-compendium: |
| 130 | +# Call the compendium workflow after updating |
| 131 | +name:call |
| 132 | +needs:[update] |
| 133 | +uses:rffontenelle/python-docs-pt-br/.github/workflows/compendium.yml@3.10 |