Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/crowdin-manual-upload-download-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Crowdin Manual Upload and Download

on:
workflow_dispatch:
inputs:
target_branch:
description: "Branch to run this workflow on"
required: true
default: "main"

jobs:
trigger-upload:
runs-on: ubuntu-latest
steps:
- name: Trigger Upload Workflow
id: trigger_upload
uses: actions/github-script@v7
with:
script: |
const targetBranch = '${{ github.event.inputs.target_branch }}' || 'main';
console.log(`Triggering upload workflow on branch: ${targetBranch}`);

const result = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'crowdin-upload-workflow.yml',
ref: targetBranch,
inputs: {
target_branch: targetBranch
}
});

console.log('Upload workflow triggered successfully');
// Store the timestamp for better polling
core.setOutput('trigger_time', Date.now().toString());
return result;

- name: Wait for Upload to Complete
uses: actions/github-script@v7
with:
script: |
const maxWaitTime = 30 * 60 * 1000; // 30 minutes
const pollInterval = 30 * 1000; // 30 seconds
const startTime = Date.now();
const targetBranch = '${{ github.event.inputs.target_branch }}' || 'main';

console.log(`Waiting for upload workflow to complete on branch: ${targetBranch}`);

// Give GitHub a moment to register the workflow dispatch
await new Promise(resolve => setTimeout(resolve, 5000));

while (Date.now() - startTime < maxWaitTime) {
// Get recent workflow runs for upload workflow
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'crowdin-upload-workflow.yml',
branch: targetBranch,
per_page: 10,
event: 'workflow_dispatch'
});

// Find the most recent run that started after we triggered it
const recentRun = runs.data.workflow_runs.find(run =>
new Date(run.created_at).getTime() > startTime - 10000 // 10 second buffer before trigger
);

if (recentRun) {
console.log(`Upload workflow status: ${recentRun.status} - ${recentRun.conclusion || 'in_progress'}`);
console.log(`Workflow run URL: ${recentRun.html_url}`);

if (recentRun.status === 'completed') {
if (recentRun.conclusion === 'success') {
console.log('Upload workflow completed successfully!');
return { success: true, run_id: recentRun.id };
} else {
throw new Error(`Upload workflow failed with conclusion: ${recentRun.conclusion}`);
}
}
} else {
console.log('Waiting for upload workflow to start...');
}

// Wait before next poll
await new Promise(resolve => setTimeout(resolve, pollInterval));
}

throw new Error('Upload workflow did not complete within the timeout period');

- name: Trigger Download Workflow
uses: actions/github-script@v7
with:
script: |
const targetBranch = '${{ github.event.inputs.target_branch }}' || 'main';
console.log(`Triggering download workflow on branch: ${targetBranch}`);

const result = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'crowdin-download-workflow.yml',
ref: targetBranch,
inputs: {
target_branch: targetBranch
}
});

console.log('Download workflow triggered successfully');
console.log('Check the Actions tab to monitor the download workflow progress');
return result;