|
1 | 1 | name: Translation |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_run: |
5 | | - workflows: |
6 | | - - Test |
7 | | - branches: |
8 | | - - main |
9 | | - types: |
10 | | - - completed |
| 4 | + workflow_run: |
| 5 | + workflows: |
| 6 | + - Test |
| 7 | + branches: |
| 8 | + - main |
| 9 | + types: |
| 10 | + - completed |
| 11 | + |
| 12 | +env: |
| 13 | + I18N_BRANCH: translation/source |
11 | 14 |
|
12 | 15 | jobs: |
13 | | - build: |
14 | | - runs-on: ubuntu-latest |
15 | | - |
16 | | - steps: |
17 | | - - name: Grab the repo src |
18 | | - uses: actions/checkout@v2 |
19 | | - |
20 | | - - name: Set up Python |
21 | | - uses: actions/setup-python@v2 |
22 | | - with: |
23 | | - python-version: 3.9 |
24 | | - |
25 | | - - name: Install Python tooling |
26 | | - run: python -m pip install --upgrade nox virtualenv |
27 | | - |
28 | | - - name: Generate a fresh POT file out of RST documents |
29 | | - run: python -m nox -s translation |
30 | | - |
31 | | - - name: Commit the POT file to Git |
32 | | - run: | |
33 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
34 | | - git config --local user.name "github-actions[bot]" |
35 | | - git_hash=$(git rev-parse --short "${GITHUB_SHA}") |
36 | | - git commit -m "Update messages.pot as of version ${git_hash}" locales/messages.pot |
37 | | -
|
38 | | - - name: Check if any sources have changed since the last update |
39 | | - if: failure() |
40 | | - run: echo "There are no changes to the RST sources since the last update. Nothing to do." |
41 | | - |
42 | | - - name: >- |
43 | | - Push the updated POT file back to |
44 | | - ${{ github.repository }}@${{ github.event.repository.default_branch }} |
45 | | - on GitHub |
46 | | - run: | |
47 | | - git push --atomic origin HEAD:${{ github.event.repository.default_branch }} |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Grab the repo src |
| 21 | + uses: actions/checkout@v2 |
| 22 | + with: |
| 23 | + fetch-depth: 0 # To reach the common commit |
| 24 | + - name: Set up git user as [bot] |
| 25 | + # Refs: |
| 26 | + # * https://github.community/t/github-actions-bot-email-address/17204/6 |
| 27 | + # * https://github.com/actions/checkout/issues/13#issuecomment-724415212 |
| 28 | + |
| 29 | + |
| 30 | + - name: Switch to the translation source branch |
| 31 | + run: | |
| 32 | + sh -x |
| 33 | +
|
| 34 | + git fetch origin \ |
| 35 | + '+refs/heads/${{ |
| 36 | + env.I18N_BRANCH |
| 37 | + }}:refs/remotes/origin/${{ |
| 38 | + env.SRC_BRANCH |
| 39 | + }}' |
| 40 | +
|
| 41 | + git checkout -B '${{ env.I18N_BRANCH }}' \ |
| 42 | + 'origin/${{ env.I18N_BRANCH }}' |
| 43 | +
|
| 44 | + - name: >- |
| 45 | + Merge '${{ github.event.repository.default_branch }}' |
| 46 | + to '${{ env.I18N_BRANCH }}' |
| 47 | + run: | |
| 48 | + sh -x |
| 49 | +
|
| 50 | + git merge '${{ github.event.repository.default_branch }}' |
| 51 | +
|
| 52 | + - name: Set up Python |
| 53 | + uses: actions/setup-python@v2 |
| 54 | + with: |
| 55 | + python-version: >- |
| 56 | + 3.10 |
| 57 | +
|
| 58 | + - name: Install Python tooling |
| 59 | + run: python -m pip install --upgrade nox virtualenv |
| 60 | + |
| 61 | + - name: Generate a fresh POT file out of RST documents |
| 62 | + run: python -m nox -s translation |
| 63 | + |
| 64 | + - name: Commit the POT file to Git |
| 65 | + run: | |
| 66 | + git_hash=$(git rev-parse --short "${GITHUB_SHA}") |
| 67 | + git add --force locales/messages.pot |
| 68 | + git commit \ |
| 69 | + -m "Update messages.pot as of version ${git_hash}" \ |
| 70 | + locales/messages.pot |
| 71 | +
|
| 72 | + - name: >- |
| 73 | + Push the updated POT file back to '${{ env.I18N_BRANCH }}' |
| 74 | + branch on GitHub |
| 75 | + if: always() |
| 76 | + run: | |
| 77 | + git push --atomic origin 'HEAD:${{ env.I18N_BRANCH }}' |
0 commit comments