-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
(fixes:#19994)prevent redundant translation sync runs and enforce 30-minute delay #20004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,22 +3,64 @@ name: 🌐 Sync Translations | |
| on: | ||
| workflow_dispatch: | ||
|
|
||
| # Ensure only one sync workflow runs at a time | ||
| # Cancel any in-progress runs when a new one is triggered | ||
| concurrency: | ||
| group: translation-sync | ||
| cancel-in-progress: true | ||
|
|
||
| # We use a machine account PAT from secrets so workflows are triggered | ||
| # the default token is not needed and should be fully restricted | ||
| permissions: {} | ||
|
|
||
| jobs: | ||
| sync_translations: | ||
| name: 'Sync Translations with Crowdin' | ||
| timeout-minutes: 20 | ||
| timeout-minutes: 50 | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.MACHINE_ACCOUNT_PAT }} | ||
| ref: 'main' | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Enforce minimum 30-minute gap between syncs | ||
| run: | | ||
| echo "Checking last sync time to enforce 30-minute minimum gap..." | ||
|
|
||
| # Fetch the i18n_sync branch to check last sync time | ||
| git fetch origin i18n_sync:i18n_sync 2>/dev/null || true | ||
|
|
||
| # Get timestamp of last commit on i18n_sync (if it exists) | ||
| if git rev-parse --verify i18n_sync >/dev/null 2>&1; then | ||
| LAST_SYNC_TIME=$(git log -1 --format=%ct i18n_sync) | ||
| CURRENT_TIME=$(date +%s) | ||
| ELAPSED=$((CURRENT_TIME - LAST_SYNC_TIME)) | ||
| REMAINING=$((1800 - ELAPSED)) | ||
|
|
||
| # Defensive: ensure REMAINING is never negative | ||
| if [ $REMAINING -lt 0 ]; then | ||
| REMAINING=0 | ||
| fi | ||
|
|
||
| if [ $REMAINING -gt 0 ]; then | ||
| MINUTES=$((REMAINING / 60)) | ||
| SECONDS=$((REMAINING % 60)) | ||
| echo "Last sync was $ELAPSED seconds ago." | ||
| echo "Waiting $MINUTES minutes and $SECONDS seconds to respect Crowdin rate limiting..." | ||
| echo "Sync will start at: $(date -u -d "+${REMAINING} seconds" '+%Y-%m-%d %H:%M:%S UTC')" | ||
| sleep $REMAINING | ||
| else | ||
| echo "Last sync was $ELAPSED seconds ago (≥30 min)." | ||
| echo "Proceeding immediately." | ||
| fi | ||
| else | ||
| echo "No previous sync found on i18n_sync branch." | ||
| echo "Proceeding immediately." | ||
| fi | ||
| shell: bash | ||
|
|
||
| - name: Credential Prep | ||
| run: | | ||
| echo "CROWDIN_APIv2_PAT=${{ secrets.CROWDIN_APIv2_PAT }}" >> $GITHUB_ENV | ||
|
|
@@ -32,7 +74,7 @@ jobs: | |
| git reset --hard origin/main | ||
| shell: bash | ||
|
|
||
| - uses: actions/setup-node@v6 | ||
| - uses: actions/setup-node@v4 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these were changed because actions/checkout@v6 and actions/setup-node@v6 don’t exist and would fail at runtime. I switched them to @v4, which is the latest stable and supported version
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
? source
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://github.com/actions/checkout/releases There is no published v6 release for either action, so using @v6 would fail at runtime. I switched them to @v4, which is the latest supported version.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They exist? https://github.com/actions/checkout/releases/tag/v6.0.0 In addition: CI was working before this change using v6 This was done by dependabot: |
||
| with: | ||
| node-version: 20 | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?