Repository navigation
147 lines (125 loc) · 4.38 KB
/
Copy pathlocalize.yml
File metadata and controls
147 lines (125 loc) · 4.38 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
name: localize
permissions: {}
on:
workflow_call:
secrets:
GH_TOKEN:
required: true
env:
PYTHON_VERSION: '3.14'
jobs:
localize:
name: Update Localization
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Resolve shared workflow checkout
id: shared-workflow
env:
JOB_CONTEXT: ${{ toJSON(job) }}
run: |
repository="$(jq -r '.workflow_repository // empty' <<< "${JOB_CONTEXT}")"
sha="$(jq -r '.workflow_sha // empty' <<< "${JOB_CONTEXT}")"
if [ -z "${repository}" ] || [ -z "${sha}" ]; then
echo "Unable to resolve shared workflow repository and sha from job context." >&2
exit 1
fi
echo "repository=${repository}" >> "${GITHUB_OUTPUT}"
echo "sha=${sha}" >> "${GITHUB_OUTPUT}"
- name: Checkout lizardbyte-common
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ steps.shared-workflow.outputs.repository }}
ref: ${{ steps.shared-workflow.outputs.sha }}
path: .lizardbyte-common
- name: Install Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: true
- name: Sync Python tools
run: |
uv_sync_args=(
--project .lizardbyte-common
--frozen
--group locale
--no-default-groups
--python "${PYTHON_VERSION}"
--no-python-downloads
)
# The workflow SHA pins reviewed project code; building it installs the required lb-* entry points.
uv sync "${uv_sync_args[@]}" # NOSONAR(githubactions:S8541)
- name: Set up xgettext
run: |
sudo apt-get update -y &&
sudo apt-get --reinstall install -y \
gettext
- name: Resolve gettext template
id: template
run: |
repository_name="${GITHUB_REPOSITORY##*/}"
file="locale/${repository_name,,}.po"
echo "file=${file}" >> "${GITHUB_OUTPUT}"
- name: Update Strings
env:
FILE: ${{ steps.template.outputs.file }}
run: |
new_file=true
if [ -f "${FILE}" ]; then
rm "${FILE}"
new_file=false
fi
echo "NEW_FILE=${new_file}" >> "${GITHUB_ENV}"
uv run --project .lizardbyte-common --frozen --group locale \
--no-default-groups --no-sync \
lb-localize --root-dir "${GITHUB_WORKSPACE}" --extract
- name: git diff
if: env.NEW_FILE == 'false'
env:
FILE: ${{ steps.template.outputs.file }}
run: |
git config --global pager.diff false
git diff -- "${FILE}"
output="$(git diff --numstat -- "${FILE}" | sed -e $'s#\t# #g')"
echo "GIT_DIFF=${output}" >> "${GITHUB_ENV}"
- name: git restore
if: env.NEW_FILE == 'false'
env:
FILE: ${{ steps.template.outputs.file }}
run: |
expected="1 1 ${FILE}"
if [ "${GIT_DIFF}" = "${expected}" ]; then
git restore -- "${FILE}"
fi
- name: Clean shared tools checkout
if: always()
run: rm -rf .lizardbyte-common
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> "${GITHUB_OUTPUT}"
- name: Create/Update Pull Request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
add-paths: |
locale/*.po
token: ${{ secrets.GH_TOKEN }}
commit-message: "chore(l10n): new babel updates"
branch: localize/update
delete-branch: true
base: master
title: "chore(l10n): new babel updates"
body: |
Update report
- Updated ${{ steps.date.outputs.date }}
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: |
babel
l10n