mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-12 20:31:36 +00:00
63 lines
2.4 KiB
YAML
63 lines
2.4 KiB
YAML
name: Manual update i18n files
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
update_translations:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# Check out the repository
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
# Set up node to run the javascript
|
|
- name: Set up node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
# Runs the custom script using the local action defined in `action.yaml`
|
|
#
|
|
# The action runs the `copy_keys.js` script, which copies any unused keys
|
|
# from the English language file to other language files, and orders each
|
|
# file by key alphabetically.
|
|
#
|
|
# The only argument is the `directory`, which is where the i18n files are
|
|
# stored.
|
|
- name: Run Update JSON Files action
|
|
uses: audiobookshelf/audiobookshelf-i18n-updater@v1.0.0-beta
|
|
with:
|
|
directory: 'client/strings/' # Adjust the directory path as needed
|
|
|
|
# Does a git diff to see if any language files were changed from running
|
|
# the script. This will be false if the local script was already ran
|
|
# locally so no changes are needed for the language files.
|
|
- name: Check diff of strings
|
|
run: |
|
|
if git diff --exit-code; then
|
|
echo "CHANGED=false" >>${GITHUB_ENV}
|
|
else
|
|
echo "CHANGED=true" >>${GITHUB_ENV}
|
|
fi
|
|
|
|
|
|
# If changes were detected, create a branch with the changes and open
|
|
# a PR to `main`. This requires changing the Workflow Permissions
|
|
# to be "read and write" to create the branch and commit, and then
|
|
# also need to enable "Allow GitHub actions to create and approve PR"
|
|
# so the PR can actually be made. Also set up secrets for user email
|
|
# name if anyone cares about that since it's available in git logs anyway.
|
|
- name: If changes, commit and open PR
|
|
if: ${{ env.CHANGED == 'true' }}
|
|
run: |
|
|
branch_name="update-strings-$(git log --format=%h -n 1)"
|
|
git config user.email "${{secrets.USER_EMAIL}}"
|
|
git config user.name "${{secrets.USER_NAME}}"
|
|
git checkout -b $branch_name
|
|
git add .
|
|
git commit -m "chore: Update strings"
|
|
git push origin $branch_name
|
|
gh pr create -B main -H $branch_name --title 'Automatic translation updates' --body 'Created by GH Action. Can be ignored if there are other open translation PRs.'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|