@@ -90,43 +90,10 @@ jobs:
9090
9191 - name : Post plan to PR
9292 if : github.event_name == 'pull_request'
93- uses : actions/github-script@v7
94- with :
95- script : |
96- const fs = require('fs');
97- const planPath = '${{ env.TF_ROOT }}/plan-output.txt';
98- let plan = '';
99- try {
100- plan = fs.readFileSync(planPath, 'utf8');
101- } catch (e) {
102- plan = 'Plan output not available.';
103- }
104- // Truncate to fit GitHub comment limits
105- if (plan.length > 60000) {
106- plan = plan.substring(0, 60000) + '\n\n... (truncated)';
107- }
108- const hasChanges = '${{ steps.plan.outputs.has_changes }}' === 'true';
109- const status = hasChanges ? '**Changes detected** — review required.' : '**No changes** — infrastructure is up to date.';
110- const body = [
111- '## Terraform Plan',
112- '',
113- status,
114- '',
115- '<details><summary>Plan output</summary>',
116- '',
117- '```',
118- plan,
119- '```',
120- '',
121- '</details>'
122- ].join('\n');
123-
124- await github.rest.issues.createComment({
125- issue_number: context.issue.number,
126- owner: context.repo.owner,
127- repo: context.repo.repo,
128- body: body
129- });
93+ env :
94+ GH_TOKEN : ${{ github.token }}
95+ PR_NUMBER : ${{ github.event.pull_request.number }}
96+ run : sh scripts/post-plan-comment.sh "${{ env.TF_ROOT }}/plan-output.txt" "${{ steps.plan.outputs.has_changes }}"
13097
13198 # --------------------------------------------------------------------------
13299 # Review — LLM risk analysis via Bedrock
@@ -158,38 +125,10 @@ jobs:
158125
159126 - name : Post review to PR
160127 if : github.event_name == 'pull_request'
161- uses : actions/github-script@v7
162- with :
163- script : |
164- const fs = require('fs');
165- let review = '';
166- try {
167- review = fs.readFileSync('review-output.txt', 'utf8');
168- } catch (e) {
169- review = 'LLM review output not available.';
170- }
171- let resultJson = {};
172- try {
173- resultJson = JSON.parse(fs.readFileSync('review-result.json', 'utf8'));
174- } catch (e) {
175- resultJson = {risk: 'FAILED'};
176- }
177- const riskEmoji = {LOW: '🟢', MEDIUM: '🟡', HIGH: '🔴', FAILED: '⚪'}[resultJson.risk] || '⚪';
178-
179- const body = [
180- '## 🧠 LLM Plan Review',
181- '',
182- `**Risk: ${riskEmoji} ${resultJson.risk}**`,
183- '',
184- review
185- ].join('\n');
186-
187- await github.rest.issues.createComment({
188- issue_number: context.issue.number,
189- owner: context.repo.owner,
190- repo: context.repo.repo,
191- body: body
192- });
128+ env :
129+ GH_TOKEN : ${{ github.token }}
130+ PR_NUMBER : ${{ github.event.pull_request.number }}
131+ run : sh scripts/post-review-comment.sh
193132
194133 - name : Post HIGH risk to Slack
195134 if : steps.review.outputs.risk_level == 'HIGH' && github.ref == 'refs/heads/main'
0 commit comments