Skip to content

Update translate files #2007

Update translate files

Update translate files #2007

Workflow file for this run

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|&quot;|"|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 時に翻訳所から最新の翻訳が反映されます。