Skip to content

Commit 09e0e59

Browse files
committed
Enable annotations for Terraform CI
1 parent 43a332e commit 09e0e59

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

.github/workflows/terraform-ci.yml

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
permissions:
1313
contents: read
1414
pull-requests: write
15+
security-events: write
1516

1617
jobs:
1718
terraform-ci:
@@ -51,22 +52,39 @@ jobs:
5152
with:
5253
tflint_version: latest
5354

54-
- name: Run TFLint
55-
run: tflint --recursive
56-
working-directory: infra
55+
- name: Run TFLint (with annotations)
56+
uses: terraform-linters/tflint-pr-commenter-action@v1
57+
with:
58+
github_token: ${{ secrets.GITHUB_TOKEN }}
59+
tflint_command: "tflint --recursive"
60+
directory: "infra"
5761

58-
- name: Run tfsec
62+
- name: Run tfsec (SARIF)
5963
uses: aquasecurity/tfsec-action@v1.0.3
6064
with:
6165
working_directory: infra
6266
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
format: sarif
68+
output_file: tfsec.sarif
69+
70+
- name: Upload tfsec SARIF
71+
uses: github/codeql-action/upload-sarif@v3
72+
with:
73+
sarif_file: tfsec.sarif
6374

64-
- name: Run Checkov
75+
- name: Run Checkov (SARIF)
6576
uses: bridgecrewio/checkov-action@v12
6677
with:
6778
directory: infra
6879
config_file: .checkov.yml
6980
quiet: true
81+
output_format: sarif
82+
output_file_path: checkov.sarif
83+
84+
- name: Upload Checkov SARIF
85+
uses: github/codeql-action/upload-sarif@v3
86+
with:
87+
sarif_file: checkov.sarif
7088

7189
- name: Publish Terraform CI summary
7290
if: ${{ success() }}
@@ -108,28 +126,3 @@ jobs:
108126
body
109127
});
110128
}
111-
112-
- name: Comment on PR with Terraform CI result
113-
if: always()
114-
uses: actions/github-script@v7
115-
with:
116-
github-token: ${{ secrets.GITHUB_TOKEN }}
117-
script: |
118-
const conclusion = '${{ job.status }}';
119-
const symbols = { success: '✅', failure: '❌', cancelled: '⚪️' };
120-
const symbol = symbols[conclusion] || 'ℹ️';
121-
const body =
122-
`${symbol} Terraform CI finished with status: **${conclusion}**\n\n` +
123-
`Terraform versions tested: 1.6.6, 1.8.5, 1.9.5.\n` +
124-
`See detailed results in the "Checks" tab.`;
125-
const pr = context.payload.pull_request;
126-
if (!pr) {
127-
core.info('No pull_request context, skipping comment.');
128-
} else {
129-
await github.rest.issues.createComment({
130-
owner: context.repo.owner,
131-
repo: context.repo.repo,
132-
issue_number: pr.number,
133-
body
134-
});
135-
}

0 commit comments

Comments
 (0)