|
| 1 | +name: "Wrap all po files in branch" |
| 2 | + |
| 3 | +on: workflow_dispatch |
| 4 | + |
| 5 | +jobs: |
| 6 | + wrap: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + # Run in all these versions of Python |
| 12 | + python-version: ["3.10"] |
| 13 | + |
| 14 | + steps: |
| 15 | + # Checkout the latest code from the repo |
| 16 | + - name: Checkout repo |
| 17 | + uses: actions/checkout@v2 |
| 18 | + |
| 19 | + # Setup which version of Python to use |
| 20 | + - name: Set Up Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v2 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + |
| 25 | + # Display the Python version being used |
| 26 | + - name: Display Python version |
| 27 | + run: python -c "import sys; print(sys.version)" |
| 28 | + |
| 29 | + # Update pip |
| 30 | + - name: Update pip |
| 31 | + run: python -m pip install --upgrade pip |
| 32 | + |
| 33 | + # Install requirements. |
| 34 | + - name: Install requirements |
| 35 | + run: python -m pip install --upgrade -r requirements.txt |
| 36 | + |
| 37 | + # Install dependencies |
| 38 | + - name: Install dependencies |
| 39 | + run: sudo apt install gettext |
| 40 | + |
| 41 | + # Wrap all po files |
| 42 | + - name: Wrap |
| 43 | + run: powrap *.po **/*.po |
| 44 | + |
| 45 | + # Detect changed files |
| 46 | + - name: Detect changed files |
| 47 | + run: echo "WRAPPED=$(git diff --name-only | tr '\n' ' ')" >> $GITHUB_ENV |
| 48 | + |
| 49 | + # Commit changes |
| 50 | + - name: Commit changes |
| 51 | + run: | |
| 52 | + array=($WRAPPED) |
| 53 | + len=${#array[@]} |
| 54 | + if [[ $len -eq 0 ]]; then |
| 55 | + echo "No files to commit" |
| 56 | + echo "WRAPPED=False" >> $GITHUB_ENV |
| 57 | + else |
| 58 | + echo "Committing changes" |
| 59 | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 60 | + git config --local user.name "github-actions[bot]" |
| 61 | + git add ${WRAPPED} |
| 62 | + git commit -m "Wrap translations" |
| 63 | + echo "WRAPPED=True" >> $GITHUB_ENV |
| 64 | + fi |
| 65 | + # Push changes |
| 66 | + - name: Push changes |
| 67 | + if: env.WRAPPED == 'True' |
| 68 | + uses: ad-m/github-push-action@master |
| 69 | + with: |
| 70 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + branch: ${{ github.ref_name }} |
0 commit comments