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