Update Chinese (Traditional) Translation #19487
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Chinese (Traditional) Translation | |
on: | |
schedule: | |
- cron: "0 * * * *" | |
workflow_dispatch: | |
jobs: | |
update-translation: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
id: checkout | |
uses: actions/checkout@v2 | |
- name: Install jq and unzip | |
run: | | |
sudo apt-get install -y jq unzip opencc | |
- name: "call action" | |
id: last_release | |
uses: InsonusK/[email protected] | |
with: | |
myToken: ${{ github.token }} | |
view_top: 1 | |
- name: Download pf2_cn.zip | |
run: wget https://github.com/losyky/pf2e_cn/releases/latest/download/pf2_cn.zip -O ./.github/pf2_cn.zip | |
- name: Unzip module.json from pf2_cn.zip | |
run: unzip -p ./.github/pf2_cn.zip 'module.json' >./.github/module.json | |
- name: Read version from module.json | |
id: read_version | |
run: | | |
echo "version=$(jq -r '.version' ./.github/module.json)" >> $GITHUB_OUTPUT | |
echo "version=$(jq -r '.version' ./.github/module.json)" | |
rm ./.github/module.json | |
- name: Print version | |
run: | | |
echo "tag_name: ${{ steps.last_release.outputs.tag_name }}" | |
echo ${{ steps.last_release.outputs.tag_name }} | |
- name: Convert cn.json to zh-tw.json | |
if: ${{ steps.last_release.outputs.tag_name != steps.read_version.outputs.version }} | |
run: | | |
mkdir -p ./.github/${{ steps.read_version.outputs.version }} | |
unzip ./.github/pf2_cn.zip -d ./.github/${{ steps.read_version.outputs.version }} | |
opencc -i ./.github/${{ steps.read_version.outputs.version }}/cn.json -o ./.github/${{ steps.read_version.outputs.version }}/zh-tw.json -c s2tw.json | |
- name: Convert re-cn.json to re-zh-tw.json | |
if: ${{ steps.last_release.outputs.tag_name != steps.read_version.outputs.version }} | |
run: opencc -i ./.github/${{ steps.read_version.outputs.version }}/re-cn.json -o ./.github/${{ steps.read_version.outputs.version }}/re-zh-tw.json -c s2tw.json | |
- name: Convert action-zh_Hans.json to action-zh-tw.json | |
if: ${{ steps.last_release.outputs.tag_name != steps.read_version.outputs.version }} | |
run: opencc -i ./.github/${{ steps.read_version.outputs.version }}/action-zh_Hans.json -o ./.github/${{ steps.read_version.outputs.version }}/action-zh-tw.json -c s2tw.json | |
- name: Convert kingmaker-zh_Hans.json to kingmaker-zh-tw.json | |
if: ${{ steps.last_release.outputs.tag_name != steps.read_version.outputs.version }} | |
run: opencc -i ./.github/${{ steps.read_version.outputs.version }}/kingmaker-zh_Hans.json -o ./.github/${{ steps.read_version.outputs.version }}/kingmaker-zh-tw.json -c s2tw.json | |
- name: Update version in module.json | |
if: ${{ steps.last_release.outputs.tag_name != steps.read_version.outputs.version }} | |
run: jq --arg ver "${{ steps.read_version.outputs.version }}" '.version=$ver' module.json > ./.github/${{ steps.read_version.outputs.version }}/module.json | |
- name: Create Artifact | |
id: build-zip | |
if: ${{ steps.last_release.outputs.tag_name != steps.read_version.outputs.version }} | |
run: zip -j -r ./.github/${{ steps.read_version.outputs.version }}/module.zip ./.github/${{ steps.read_version.outputs.version }}/module.json ./.github/${{ steps.read_version.outputs.version }}/re-zh-tw.json ./.github/${{ steps.read_version.outputs.version }}/zh-tw.json ./.github/${{ steps.read_version.outputs.version }}/kingmaker-zh-tw.json ./.github/${{ steps.read_version.outputs.version }}/action-zh-tw.json | |
- name: Update Release with Files | |
if: ${{ steps.last_release.outputs.tag_name != steps.read_version.outputs.version }} | |
id: create_version_release | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
artifacts: "./.github/${{ steps.read_version.outputs.version }}/module.zip, ./.github/${{ steps.read_version.outputs.version }}/module.json" | |
tag: ${{ steps.read_version.outputs.version }} |