-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the OTA translation updates action more robust: Split checking PO validity and uploading into separate steps and if there are errors, still upload the rest of the files. Otherwise one bad translation was blocking everything else. Add a separate step for checking validity so that the run fails on errors. Add logging of failed files and their content for easier debugging.
- Loading branch information
Showing
2 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,30 +7,64 @@ on: | |
- cron: '11 10 * * *' | ||
|
||
jobs: | ||
build-ota-translations: | ||
name: Build OTA translations | ||
download-translations: | ||
name: Get Crowdin translations | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install GNU gettext | ||
run: sudo apt-get install gettext | ||
|
||
- name: Install Crowdin CLI | ||
run: npm i -g @crowdin/cli | ||
|
||
- name: Download latest translations from Crowdin | ||
run: | | ||
echo 'api_token: "${{secrets.CROWDIN_PERSONAL_TOKEN}}"' >>crowdin.yaml | ||
crowdin download | ||
rm crowdin.yaml | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: translations | ||
path: locales/*.po | ||
|
||
check-po-validity: | ||
name: Check translations | ||
runs-on: ubuntu-latest | ||
needs: download-translations | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: translations | ||
path: locales | ||
- name: Install GNU gettext | ||
run: sudo apt-get install gettext | ||
- name: Check PO files with msgfmt -v -c | ||
run: | | ||
for i in locales/*.po ; do | ||
echo "checking $i..." | ||
msgfmt -v -c -o /dev/null $i | ||
done | ||
build-ota-translations: | ||
name: Build OTA translations | ||
runs-on: ubuntu-latest | ||
needs: download-translations | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: translations | ||
path: locales | ||
- name: Install GNU gettext | ||
run: sudo apt-get install gettext | ||
- name: Build OTA updates | ||
run: scripts/build-ota-translations.sh | ||
|
||
- name: Upload OTA updates | ||
run: | | ||
VERSION=$(sed -n -e 's/.*POEDIT_VERSION.* "\([0-9]*\)\.\([0-9]*\).*".*/\1.\2/p' src/version.h) | ||
echo "OTA version: $VERSION" | ||
curl --fail-with-body -F '[email protected]' -H "X-Api-Key: ${{secrets.OTA_API_KEY}}" "${{secrets.OTA_UPLOAD_ENDPOINT}}?version=${VERSION}" | ||
curl --fail-with-body -F '[email protected]' -H "X-Api-Key: ${{secrets.OTA_API_KEY}}" "${{secrets.OTA_UPLOAD_ENDPOINT}}?version=${VERSION}" | tee response | ||
modified=$(echo `jq -r '.modified[]' < response`) | ||
if [ -n "$modified" ] ; then | ||
echo "::notice title=Translations updated::Updated translation files: $modified" | ||
else | ||
echo "::notice title=No updates::No translations were updated." | ||
fi |
This file contains 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