GitHub Actions Integration
Add DriftWise to any GitHub Actions workflow that runs terraform plan.
Workflow Example
.github/workflows/terraform.yml
- name: Terraform Plan
id: plan
run: terraform plan -out=tfplan
- name: DriftWise Analysis
run: |
terraform show -json tfplan > plan.json
curl -sX POST "https://app.driftwise.ai/api/v2/orgs/${{ vars.DRIFTWISE_ORG_ID }}/analyze" \
-H "x-api-key: ${{ secrets.DRIFTWISE_API_KEY }}" \
-H "Content-Type: application/json" \
-d "{
\"plan_json\": $(cat plan.json | jq -Rs .),
\"ci\": {
\"repo_owner\": \"${{ github.repository_owner }}\",
\"repo_name\": \"${{ github.event.repository.name }}\",
\"pr_number\": ${{ github.event.pull_request.number }},
\"commit_sha\": \"${{ github.sha }}\",
\"branch\": \"${{ github.head_ref }}\"
}
}"
Secrets & Variables
Add these in your repository settings (Settings > Secrets and variables > Actions):
| Type | Name | Value |
|---|---|---|
| Secret | DRIFTWISE_API_KEY | Your API key (dw2_...) |
| Variable | DRIFTWISE_ORG_ID | Your organization ID |
Response
The endpoint returns a JSON response with the analysis. You can parse it with jq to post a PR comment or use it in subsequent steps:
- name: DriftWise Analysis
id: driftwise
run: |
terraform show -json tfplan > plan.json
RESULT=$(curl -sX POST "https://app.driftwise.ai/api/v2/orgs/${{ vars.DRIFTWISE_ORG_ID }}/analyze" \
-H "x-api-key: ${{ secrets.DRIFTWISE_API_KEY }}" \
-H "Content-Type: application/json" \
-d "{\"plan_json\": $(cat plan.json | jq -Rs .)}")
echo "risk_level=$(echo $RESULT | jq -r '.risk_level')" >> $GITHUB_OUTPUT
echo "$RESULT" | jq -r '.narrative'