Skip to content

Commit 4514904

Browse files
authored
Merge pull request #105 from anxdpanic/pr_isengard
add workflow to comment on and close translation PRs
2 parents 514f3c8 + a1c547f commit 4514904

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Close Translation Pull Requests
2+
3+
on:
4+
pull_request:
5+
branches: [ master, main, dev ]
6+
7+
jobs:
8+
9+
close-translation-prs:
10+
if: github.actor != 'weblate' && github.actor != 'anxdpanic' && github.repository == 'anxdpanic/script.module.python.twitch'
11+
12+
name: Close Translation Pull Requests
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Get changed files
17+
id: modified_files
18+
uses: trilom/file-changes-action@v1.2.4
19+
with:
20+
output: ","
21+
22+
- name: Check the PR for translations
23+
id: check
24+
run: |
25+
shopt -s nocasematch
26+
if [[ "${{ steps.modified_files.outputs.files_modified }}" == *"en_gb/strings.po"* ]]; then
27+
echo "Found modified en_gb, likely a valid PR"
28+
unset CLOSE
29+
elif [[ "${{ steps.modified_files.outputs.files_modified }}" == *"strings.po"* ]]; then
30+
echo "Found modified strings.po, unwanted."
31+
CLOSE="true"
32+
elif [[ "${{ steps.modified_files.outputs.files_added }}" == *"strings.po"* ]]; then
33+
echo "Found added strings.po, unwanted."
34+
CLOSE="true"
35+
elif [[ "${{ steps.modified_files.outputs.files_removed }}" == *"strings.po"* ]]; then
36+
echo "Found removed strings.po, unwanted."
37+
CLOSE="true"
38+
else
39+
echo "No strings.po were modified or added, not a translation."
40+
unset CLOSE
41+
fi
42+
echo ::set-output name=close::${CLOSE}
43+
44+
- name: Comment on the PR
45+
uses: mshick/add-pr-comment@v1
46+
if: ${{ steps.check.outputs.close }}
47+
with:
48+
repo-token: ${{ secrets.GITHUB_TOKEN }}
49+
repo-token-user-login: 'github-actions[bot]'
50+
allow-repeats: true
51+
message: |
52+
A modified strings.po file was detected.
53+
54+
Translations are not accepted through PRs, please use Weblate if you'd like to contribute to the translations.
55+
For more information see Issue #104.
56+
57+
If you feel this PR was closed in error, please reply below.
58+
Thank you for your interest in improving this add-on.
59+
60+
- name: Close the PR
61+
uses: peter-evans/close-pull@v1
62+
if: ${{ steps.check.outputs.close }}

0 commit comments

Comments
 (0)