1+ name : " Wrap"
2+
3+ on :
4+ pull_request :
5+ branches : [ "**" ]
6+
7+ jobs :
8+ wrap :
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+ ref : ${{ github.event.pull_request.head.ref }}
23+
24+ # Setup which version of Python to use
25+ - name : Set Up Python ${{ matrix.python-version }}
26+ uses : actions/setup-python@v2
27+ with :
28+ python-version : ${{ matrix.python-version }}
29+
30+ # Display the Python version being used
31+ - name : Display Python version
32+ run : python -c "import sys; print(sys.version)"
33+
34+ # Update pip
35+ - name : Update pip
36+ run : python -m pip install --upgrade pip
37+
38+ # Install requirements.
39+ - name : Install requirements
40+ run : python -m pip install --upgrade -r requirements.txt
41+
42+ # Install dependencies
43+ - name : Install dependencies
44+ run : sudo apt install gettext
45+
46+ # Detect changed files
47+ - name : Detect changed files
48+ run : echo "CHANGED_FILES=$(python .github/workflows/get-changes.py --pull ${{ github.event.pull_request.number }} | tr '\n' ' ')" >> $GITHUB_ENV
49+
50+ # Wrap changed files
51+ - name : Wrap
52+ run : |
53+ array=($CHANGED_FILES)
54+ len=${#array[@]}
55+ if [[ $len -eq 0 ]]; then
56+ echo "No files to wrap"
57+ else
58+ for file in ${CHANGED_FILES}; do
59+ if [[ $file == *.po ]]; then
60+ echo "Wrapping $file"
61+ powrap $file
62+ fi
63+ done
64+ fi
65+
66+ # Detect changed files
67+ - name : Detect changed files
68+ run : echo "WRAPPED=$(git diff --name-only | tr '\n' ' ')" >> $GITHUB_ENV
69+
70+ # Commit changes
71+ - name : Commit changes
72+ run : |
73+ array=($WRAPPED)
74+ len=${#array[@]}
75+ if [[ $len -eq 0 ]]; then
76+ echo "No files to commit"
77+ echo "WRAPPED=False" >> $GITHUB_ENV
78+ else
79+ echo "Committing changes"
80+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
81+ git config --local user.name "github-actions[bot]"
82+ git add ${WRAPPED}
83+ git commit -m "Wrap translations"
84+ echo "WRAPPED=True" >> $GITHUB_ENV
85+ fi
86+
87+ # Push changes
88+ - name : Push changes
89+ if : env.WRAPPED == 'True'
90+ uses : ad-m/github-push-action@master
91+ with :
92+ github_token : ${{ secrets.GITHUB_TOKEN }}
93+ branch : ${{ github.event.pull_request.head.ref }}
0 commit comments