1
- # Workflow from https://github.com/python-docs-translations/transifex-automations/blob/main/sample-workflows/transifex-pull.yml
1
+ # Workflow adapted from https://github.com/python-docs-translations/transifex-automations/blob/main/sample-workflows/transifex-pull.yml
2
2
name : Pull Translations from Transifex
3
-
4
3
on :
5
4
schedule :
6
5
- cron : ' 0 0 * * *'
7
6
workflow_dispatch :
8
7
permissions :
9
8
contents : write
10
-
9
+ pull-requests : write
11
10
jobs :
12
11
update-translation :
13
12
runs-on : ubuntu-latest
32
31
with :
33
32
ref : ${{ matrix.version }}
34
33
fetch-depth : 0
34
+ token : ${{ secrets.GITHUB_TOKEN }}
35
35
- run : curl -O https://raw.githubusercontent.com/python-docs-translations/transifex-automations/master/sample-workflows/transifex-util.py
36
36
- run : chmod +x transifex-util.py
37
37
- run : ./transifex-util.py recreate_tx_config --language id --project-slug python-newest --version 3.14
@@ -45,18 +45,46 @@ jobs:
45
45
run : |
46
46
git config --local user.email github-actions@github.com
47
47
git config --local user.name "GitHub Action's update-translation job"
48
+ - name : Check for recent manual changes
49
+ run : |
50
+ RECENT_COMMITS=$(git log --since="24 hours ago" --grep="Update translation from Transifex" --invert-grep --oneline | wc -l)
51
+ if [ "$RECENT_COMMITS" -gt 0 ]; then
52
+ echo "Recent manual commits detected:"
53
+ git log --since="24 hours ago" --grep="Update translation from Transifex" --invert-grep --oneline
54
+ echo "RECENT_MANUAL_CHANGES=1" >> $GITHUB_ENV
55
+ else
56
+ echo "No recent manual changes detected"
57
+ echo "RECENT_MANUAL_CHANGES=0" >> $GITHUB_ENV
58
+ fi
48
59
- name : Filter files
49
60
run : |
50
61
! git diff -I'^"POT-Creation-Date: ' \
51
62
-I'^"Language-Team: ' \
52
63
-I'^# ' -I'^"Last-Translator: ' \
53
64
--exit-code \
54
65
&& echo "SIGNIFICANT_CHANGES=1" >> $GITHUB_ENV || exit 0
55
- - run : git add .
56
- - run : git commit -m 'Update translation from Transifex'
57
- if : env.SIGNIFICANT_CHANGES
58
- - uses : ad-m/github-push-action@master
59
- if : env.SIGNIFICANT_CHANGES
66
+ - name : Create Pull Request if recent manual changes exist
67
+ if : env.SIGNIFICANT_CHANGES == '1' && env.RECENT_MANUAL_CHANGES == '1'
68
+ uses : peter-evans/create-pull-request@v5
60
69
with :
61
- branch : ${{ matrix.version }}
62
- github_token : ${{ secrets.GITHUB_TOKEN }}
70
+ token : ${{ secrets.GITHUB_TOKEN }}
71
+ branch : transifex-updates-${{ matrix.version }}-${{ github.run_number }}
72
+ title : ' Update translations from Transifex for ${{ matrix.version }}'
73
+ body : |
74
+ Automated translation updates from Transifex
75
+
76
+ **Manual changes detected in the last 24 hours** - please review carefully to avoid conflicts.
77
+
78
+ Recent manual commits:
79
+ ```
80
+ $(git log --since="24 hours ago" --grep="Update translation from Transifex" --invert-grep --oneline)
81
+ ```
82
+
83
+ base : ${{ matrix.version }}
84
+ delete-branch : true
85
+ - name : Commit and push directly if no recent manual changes
86
+ if : env.SIGNIFICANT_CHANGES == '1' && env.RECENT_MANUAL_CHANGES == '0'
87
+ run : |
88
+ git add .
89
+ git commit -m 'Update translation from Transifex'
90
+ git push origin ${{ matrix.version }}
0 commit comments