@@ -13,17 +13,19 @@ jobs:
1313 github.event.workflow_run.conclusion == 'success' &&
1414 github.event.workflow_run.event == 'pull_request'
1515 steps :
16- - name : Check and deploy approved fork PR
16+ - name : Download PR information
17+ uses : actions/download-artifact@v4
18+ with :
19+ name : pr
20+ github-token : ${{ secrets.GITHUB_TOKEN }}
21+ run-id : ${{ github.event.workflow_run.id }}
22+
23+ - name : Read PR information and trigger deployment
1724 uses : actions/github-script@v7
1825 with :
1926 script : |
20- // Get the PR that triggered the workflow
21- const pr = context.payload.workflow_run.pull_requests[0];
22- if (!pr) {
23- core.setFailed('No PR found in workflow run');
24- return;
25- }
26-
27+ const fs = require('fs');
28+
2729 // Check if this was a fork PR by checking if approve-fork job ran
2830 const jobs = await github.rest.actions.listJobsForWorkflowRun({
2931 owner: context.repo.owner,
@@ -36,18 +38,29 @@ jobs:
3638 core.setFailed('Not a fork PR approval workflow run');
3739 return;
3840 }
41+
42+ // Read PR information from artifacts
43+ let prNumber, prHeadSha, prCheckoutRepo;
44+ try {
45+ prNumber = fs.readFileSync('./pr_number', 'utf8').trim();
46+ prHeadSha = fs.readFileSync('./pr_head_sha', 'utf8').trim();
47+ prCheckoutRepo = fs.readFileSync('./pr_checkout_repository', 'utf8').trim();
48+ } catch (error) {
49+ core.setFailed(`Failed to read PR information: ${error.message}`);
50+ return;
51+ }
3952
40- console.log(`Deploying approved fork PR #${pr.number }`);
53+ console.log(`Deploying approved fork PR #${prNumber }`);
4154
4255 // Trigger deployment via repository dispatch
4356 await github.rest.repos.createDispatchEvent({
4457 owner: context.repo.owner,
4558 repo: context.repo.repo,
4659 event_type: 'pr-preview-deploy',
4760 client_payload: {
48- pr_number: String(pr.number) ,
49- pr_head_sha: pr.head.sha ,
50- pr_checkout_repository: pr.head.repo.full_name ,
61+ pr_number: prNumber ,
62+ pr_head_sha: prHeadSha ,
63+ pr_checkout_repository: prCheckoutRepo ,
5164 is_fork: 'true'
5265 }
5366 });
0 commit comments