File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,14 +3,18 @@ name: 🌐 Sync Translations
33on :
44 workflow_dispatch :
55
6+ concurrency :
7+ group : sync-translations
8+ cancel-in-progress : true
9+
610# We use a machine account PAT from secrets so workflows are triggered
711# the default token is not needed and should be fully restricted
812permissions : {}
913
1014jobs :
1115 sync_translations :
1216 name : ' Sync Translations with Crowdin'
13- timeout-minutes : 20
17+ timeout-minutes : 50
1418 runs-on : ubuntu-latest
1519 steps :
1620 - uses : actions/checkout@v6
3236 git reset --hard origin/main
3337 shell : bash
3438
39+ - name : Get second to latest run time
40+ env :
41+ GH_TOKEN : ${{ secrets.MACHINE_ACCOUNT_PAT }}
42+ run : |
43+ OUTPUT=$(gh run list --workflow sync_translations.yml --json updatedAt | jq -r '.[1].updatedAt')
44+ echo "LATEST_RUN=$OUTPUT" >> $GITHUB_ENV
45+
46+ - name : Calculate seconds passed
47+ id : calc_time
48+ uses : actions/github-script@v8
49+ with :
50+ script : |
51+ const lastRun = new Date(process.env.LATEST_RUN);
52+ const secondsPassed = Math.floor((Date.now() - lastRun.getTime()) / 1000);
53+ const timeLeft = 1800 - secondsPassed > 0 ? 1800 - secondsPassed: 0;
54+ console.log('Seconds to sleep for: ' + timeLeft);
55+ core.setOutput('time_left', timeLeft);
56+
57+ - name : Await CrowdIn API Cooldown If Needed
58+ if : steps.calc_time.outputs.time_left > 0
59+ run : sleep ${{ steps.calc_time.outputs.time_left }}
60+
3561 - uses : actions/setup-node@v6
3662 with :
3763 node-version : 20
You can’t perform that action at this time.
0 commit comments