fix(*): added the delay in every api call #3
Workflow file for this run
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
name: Sync Translations with POEditor | |
on: | |
push: | |
branches: | |
- feat/manage-translation-poeditor-integration | |
jobs: | |
sync-translations: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up node | |
uses: actions/setup-node@v4 | |
- name: Install dependencies | |
run: npm ci | |
# Extract new translation keys for all languages | |
- name: Extract i18n keys | |
run: npm run extract-i18n | |
- name: Upload translations to POEditor | |
run: | | |
# Upload the default English file | |
curl -X POST https://api.poeditor.com/v2/projects/upload \ | |
-F "api_token=56acaf6808f07eb52c5b39a3abea19a7" \ | |
-F "id=740876" \ | |
-F "language=en" \ | |
-F "updating=terms_translations" \ | |
-F "file=@src/assets/locale/messages.xlf" | |
echo "Waiting for 1 minutes to respect rate limit..." | |
sleep 60 | |
# Upload other language files | |
for lang in fr de it; do | |
curl -X POST https://api.poeditor.com/v2/projects/upload \ | |
-F "api_token=56acaf6808f07eb52c5b39a3abea19a7" \ | |
-F "id=740876" \ | |
-F "language=$lang" \ | |
-F "updating=terms_translations" \ | |
-F "file=@src/assets/locale/messages.$lang.xlf" | |
echo "Waiting for 1 minutes to respect rate limit..." | |
sleep 60 | |
done | |
# Export updated translations from POEditor | |
- name: Export updated translations | |
run: | | |
response=$(curl -X POST https://api.poeditor.com/v2/projects/export \ | |
-F "api_token=56acaf6808f07eb52c5b39a3abea19a7" \ | |
-F "id=740876" \ | |
-F "language=end" \ | |
-F "type=xlf") | |
url=$(echo $response | jq -r '.result.url') | |
curl -L $url -o src/assets/locale/messages.xlf | |
echo "Waiting for 1 minutes to respect rate limit..." | |
sleep 60 | |
for lang in fr de it; do | |
response=$(curl -X POST https://api.poeditor.com/v2/projects/export \ | |
-F "api_token=56acaf6808f07eb52c5b39a3abea19a7" \ | |
-F "id=740876" \ | |
-F "language=$lang" \ | |
-F "type=xlf") | |
url=$(echo $response | jq -r '.result.url') | |
curl -L $url -o src/assets/locale/messages.$lang.xlf | |
echo "Waiting for 1 minutes to respect rate limit..." | |
sleep 60 | |
done | |
# Commit and create a new PR | |
- name: Configure Git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Create new branch for translations | |
run: | | |
git checkout -b update-translations | |
git add src/assets/locale/messages.xlf | |
git add src/assets/locale/messages.*.xlf | |
git commit -m "Update translations from POEditor" | |
- name: Push changes | |
run: git push origin update-translations | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
branch: update-translations | |
title: "Update translations from POEditor" | |
body: "This PR updates the translations exported from POEditor." | |
labels: translations |