Skip to content

Feat: Automate sync_translations workflow for 30 minute delays#20758

Open
LUwUcifer wants to merge 1 commit intoankidroid:mainfrom
LUwUcifer:schedule-translations-sync
Open

Feat: Automate sync_translations workflow for 30 minute delays#20758
LUwUcifer wants to merge 1 commit intoankidroid:mainfrom
LUwUcifer:schedule-translations-sync

Conversation

@LUwUcifer
Copy link
Copy Markdown
Contributor

Note

A new github environment key by the name of LATEST_RUN must be created for this to function

Purpose / Description

30 minute delays are necessary between every sync translation workflow run, requiring manual oversight

Fixes

Approach

  1. Uses gh commands to get datetime of last workflow run
  2. Uses javascript to calculate time to 30 minutes
  3. Runs sleep on remaining time

How Has This Been Tested?

The functionality of these commands have been tested exclusively on a repository explicitly created for this
Sleep Function has proven to work as intended
image

Links to blog posts, patterns, libraries or addons used to solve this problem

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@LUwUcifer
Copy link
Copy Markdown
Contributor Author

Requesting Review from @mikehardy

core.setOutput('time_left', timeLeft);

- name: Sleep until completion
if: steps.calc_time.outputs.time_left > 0
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if I should remove the redundant time check, i implemented it here because calc_time seems prone to mutability

Comment thread .github/workflows/sync_translations.yml Outdated
env:
GH_TOKEN: ${{ secrets.MACHINE_ACCOUNT_PAT }}
run: |
OUTPUT=$(gh run list --workflow sync_translations.yml --json startedAt | jq -r '.[1].startedAt')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why started? There's a 30 minute API cool down, and a faster execution on round 2 would still hit a rate limit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, updated the code to reflect the latest state

Copy link
Copy Markdown
Contributor Author

@LUwUcifer LUwUcifer Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a 30 minute API cool down

The API isnt used until yarn build no? 30 min sleep before should work as intended

@LUwUcifer LUwUcifer force-pushed the schedule-translations-sync branch 2 times, most recently from 95326ed to 8b6f6c2 Compare April 17, 2026 02:11
Copy link
Copy Markdown
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting - I really like the approach of interrogating the github API to determine workflow run history - but I'm not so sure on the details of the implementation - seems really close though

Comment thread .github/workflows/sync_translations.yml Outdated
env:
GH_TOKEN: ${{ secrets.MACHINE_ACCOUNT_PAT }}
run: |
OUTPUT=$(gh run list --workflow sync_translations.yml --json updatedAt | jq -r '.[1].updatedAt')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only want runs that succeeded or failed I think, and should filter out runs that were cancelled, it is possible that the latest run started, and then because of the concurrency group set to cancel in progress above takes effect - a previous run was cancelled and now we get a last updated timestamp that was just before this run...but crowdin API cooldown has on relation to that sequence of events

crowdin API cooldown only cares about runs that actually hit the API (and then either succeeded or failed), thus my thought that cancelled runs should be filtered out

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that scenario we have to consider that the run cancelled from concurrency 'hit the api' before being cancelled, it would fail the new workflow if filtered out

@LUwUcifer LUwUcifer force-pushed the schedule-translations-sync branch from 8b6f6c2 to d8a75b7 Compare April 17, 2026 14:44
@LUwUcifer
Copy link
Copy Markdown
Contributor Author

the gh command was extrapolated from various doc pages like this, should I add comments breaking the command down?

@LUwUcifer LUwUcifer requested a review from mikehardy April 17, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schedule Sync translations action to run 30 minutes after the last one.

3 participants