forked from dair-ai/Prompt-Engineering-Guide
44 lines (42 loc) 路 1.4 KB
/
rename_l10n_files.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
name: Rename l10n files
on:
push:
branches: [ l10n_test ]
tags:
- '*'
jobs:
rename_l10n_files:
concurrency:
group: l10n_rename
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Rename l10n files
run: |
renames=$(find -type f -iwholename "*/*.en.??.*")
if [ -n "$renames" ]; then
git config --global user.name "github-actions"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
#git fetch --force
for f in $renames; do
filename=$(basename -- "$f" | sed 's/\.en\..*\..*$//')
tlc=$(echo $f | sed 's/^.*\.en\.\([^.]*\)\..*$/\1/')
ext=$(echo $f | sed 's/^.*\.\([^.]*\)$/\1/')
dirname=$(dirname -- "$f")
git mv -v $f "${dirname}/${filename}.${tlc}.${ext}"
done
git status --porcelain | grep -E "^R"
if [ $? -eq 0 ]; then
git add --all
GIT_COMMITTER_DATE="$(date -R)" git commit -v -m "chore(l10n): Rename l10n files"
git push
else
echo "Nothing to commit, working tree clean"
fi
else
echo "No file to rename"
fi