From 9f21d6b936d2c99aedb51c9453670fba091309cf Mon Sep 17 00:00:00 2001 From: Soma Harmath Date: Tue, 11 Nov 2025 13:31:01 +0100 Subject: [PATCH] add manual upload download action --- ...rowdin-manual-upload-download-workflow.yml | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .github/workflows/crowdin-manual-upload-download-workflow.yml diff --git a/.github/workflows/crowdin-manual-upload-download-workflow.yml b/.github/workflows/crowdin-manual-upload-download-workflow.yml new file mode 100644 index 000000000..82bbe3de1 --- /dev/null +++ b/.github/workflows/crowdin-manual-upload-download-workflow.yml @@ -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;