Skip to content

Commit 7bd0321

Browse files
areinclaude
andcommitted
feat: add Claude AI review for terraform plans
- Add optional ANTHROPIC_API_KEY secret to ci-plan-infra.yml - Save terraform plan output to file for artifact upload - Upload plan output as artifact on PRs - Add Claude AI review step when ANTHROPIC_API_KEY is provided - Add pull-requests: write permission for PR comments This enables automatic AI review of terraform plans for any repo that provides the ANTHROPIC_API_KEY secret. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1673244 commit 7bd0321

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

.github/workflows/ci-plan-infra.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ on:
4242
secrets:
4343
TF_API_TOKEN:
4444
required: true
45+
ANTHROPIC_API_KEY:
46+
required: false
4547

4648
permissions:
4749
contents: read
4850
id-token: write
51+
pull-requests: write
4952

5053
concurrency: deploy-${{ inputs.stage }}
5154

@@ -106,7 +109,25 @@ jobs:
106109
107110
- name: Plan ${{ inputs.stage }}
108111
working-directory: ${{ inputs.tf-directory }}
109-
run: terraform plan -no-color
112+
run: |
113+
set -o pipefail
114+
terraform plan -no-color 2>&1 | tee /tmp/plan_output.txt
115+
116+
- name: Upload Plan Output
117+
if: always() && github.event_name == 'pull_request'
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: terraform-plan-${{ inputs.stage }}
121+
path: /tmp/plan_output.txt
122+
retention-days: 1
123+
124+
- name: Claude AI Review
125+
if: github.event_name == 'pull_request' && secrets.ANTHROPIC_API_KEY != ''
126+
continue-on-error: true
127+
uses: WalletConnect/actions/claude/terraform-plan-review@master
128+
with:
129+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
130+
terraform_plan_file: /tmp/plan_output.txt
110131

111132
- name: Delete Grafana key
112133
if: ${{ always() }}

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,14 @@ on:
108108
secrets:
109109
TF_API_TOKEN:
110110
required: true
111+
ANTHROPIC_API_KEY:
112+
required: false
113+
description: 'Anthropic API key for Claude AI terraform plan review'
111114

112115
permissions:
113116
contents: read
114117
id-token: write
118+
pull-requests: write
115119

116120
jobs:
117121
check-app:

0 commit comments

Comments
 (0)