-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (66 loc) · 2.41 KB
/
translate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Update translate files
on:
push:
branches:
- master
repository_dispatch:
types: [update_translate]
schedule:
- cron: "0 21 * * *"
workflow_dispatch:
jobs:
translate:
runs-on: ubuntu-latest
steps:
- name: Checkout via SSH
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
- name: Checkout `translate`
run: gh pr checkout translate || git switch -c translate
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Get current date
id: date
run: echo "::set-output name=date::$(TZ='JST-9' date +'%Y/%m/%d %H:%M:%S')"
- name: Download translate file
run: |
curl -sL -o translations.txt ${{ secrets.TRANSLATE_URL }}
base64 -d <translations.txt >translations.zip || result=$?
if [ $result -gt 0 ]; then
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' translations.txt |
grep -oP '<div style="[^"]+">.+</div>' |
sed -re 's|<[^>]+>||g' |
sed -e 's|"|"|g' |
echo "::error::$(cat)"
exit 1
fi
unzip -oq translations.zip -d game/tl/Japanese/
rm translations.txt translations.zip
- name: Commit translate file
id: commit
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions[bot]
author_email: 41898282+github-actions[bot]@users.noreply.github.com
message: ":sparkles: 翻訳の更新 (${{ steps.date.outputs.date }} までの変更を反映)"
new_branch: translate
- name: Create or Update Pull Request
if: steps.commit.outputs.committed == 'true'
run: |
if [ 'OPEN' != "$(gh pr view translate --json state -q .state 2>/dev/null)" ]; then
gh pr create \
--title "$PR_TITLE" \
--body "$PR_BODY" \
--label 'automated pr' \
--assignee proudust \
--reviewer proudust
else
gh pr edit --title "$PR_TITLE"
fi
env:
GITHUB_TOKEN: ${{ github.token }}
PR_TITLE: 翻訳の更新 (${{ steps.date.outputs.date }} までの変更を反映)
PR_BODY: |
この Pull Request は GitHub Actions により自動生成されています。
毎朝 6 時に翻訳所から最新の翻訳が反映されます。