@@ -25,12 +25,15 @@ jobs:
2525 steps :
2626 - name : Download analysis artifacts
2727 uses : actions/github-script@v7
28+ env :
29+ WORKFLOW_RUN_ID : ${{ github.event.workflow_run.id }}
2830 with :
2931 script : |
32+ const runId = process.env.WORKFLOW_RUN_ID;
3033 const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
3134 owner: context.repo.owner,
3235 repo: context.repo.repo,
33- run_id: ${{ github.event.workflow_run.id }} ,
36+ run_id: runId ,
3437 });
3538
3639 const matchArtifact = artifacts.data.artifacts.find((artifact) => {
5053 });
5154
5255 const fs = require('fs');
53- fs.writeFileSync('${{ github.workspace }} /pr-analysis.zip' , Buffer.from(download.data));
56+ fs.writeFileSync(`${process.env.GITHUB_WORKSPACE} /pr-analysis.zip` , Buffer.from(download.data));
5457
5558 - name : Extract and validate artifacts
5659 id : extract-data
@@ -80,11 +83,17 @@ jobs:
8083
8184 - name : Post AI review comment
8285 uses : actions/github-script@v7
86+ env :
87+ PR_NUMBER : ${{ steps.extract-data.outputs.pr-number }}
88+ HEAD_SHA : ${{ steps.extract-data.outputs.head-sha }}
89+ AUTHOR : ${{ steps.extract-data.outputs.author }}
90+ WORKFLOW_URL : ${{ github.event.workflow_run.html_url }}
8391 with :
8492 script : |
85- const prNumber = ${{ steps.extract-data.outputs.pr-number }};
86- const headSha = "${{ steps.extract-data.outputs.head-sha }}";
87- const author = "${{ steps.extract-data.outputs.author }}";
93+ const prNumber = process.env.PR_NUMBER;
94+ const headSha = process.env.HEAD_SHA;
95+ const author = process.env.AUTHOR;
96+ const workflowUrl = process.env.WORKFLOW_URL;
8897
8998 // Validate inputs
9099 if (!prNumber || !headSha) {
@@ -132,7 +141,7 @@ jobs:
132141
133142 > 🔄 **Note:** This analysis was performed securely without executing untrusted code
134143
135- **Analysis Workflow:** [View Details](${{ github.event.workflow_run.html_url } })
144+ **Analysis Workflow:** [View Details](${workflowUrl })
136145 `;
137146
138147 await github.rest.issues.createComment({
@@ -153,13 +162,16 @@ jobs:
153162 - name : Download failure artifacts (if any)
154163 uses : actions/github-script@v7
155164 continue-on-error : true
165+ env :
166+ WORKFLOW_RUN_ID : ${{ github.event.workflow_run.id }}
156167 with :
157168 script : |
158169 try {
170+ const runId = process.env.WORKFLOW_RUN_ID;
159171 const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
160172 owner: context.repo.owner,
161173 repo: context.repo.repo,
162- run_id: ${{ github.event.workflow_run.id }} ,
174+ run_id: runId ,
163175 });
164176
165177 const matchArtifact = artifacts.data.artifacts.find((artifact) => {
@@ -196,9 +208,13 @@ jobs:
196208
197209 - name : Create failure issue
198210 uses : actions/github-script@v7
211+ env :
212+ PR_NUMBER : ${{ steps.extract-pr.outputs.pr-number }}
213+ WORKFLOW_HTML_URL : ${{ github.event.workflow_run.html_url }}
199214 with :
200215 script : |
201- const prNumber = "${{ steps.extract-pr.outputs.pr-number }}";
216+ const prNumber = process.env.PR_NUMBER;
217+ const workflowUrl = process.env.WORKFLOW_HTML_URL;
202218
203219 const title = `🚨 AI Analysis Failed${prNumber ? ` for PR #${prNumber}` : ''}`;
204220 const body = `
@@ -207,7 +223,7 @@ jobs:
207223 The automated AI code analysis workflow has failed and requires attention.
208224
209225 ${prNumber ? `**Pull Request:** #${prNumber}` : '**Pull Request:** Unable to determine'}
210- **Workflow Run:** ${{ github.event.workflow_run.html_url } }
226+ **Workflow Run:** ${workflowUrl }
211227 **Failure Time:** ${new Date().toISOString()}
212228
213229 ### Possible Causes
0 commit comments