Skip to content

Commit e37f32e

Browse files
committed
Add Terraform CI job summary
1 parent eac67e7 commit e37f32e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/terraform-ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,47 @@ jobs:
6868
config_file: .checkov.yml
6969
quiet: true
7070

71+
- name: Publish Terraform CI summary
72+
if: ${{ success() }}
73+
run: |
74+
cat << EOF >> "$GITHUB_STEP_SUMMARY"
75+
# Terraform CI Summary
76+
77+
- Terraform version (matrix): \`${{ matrix.terraform_version }}\`
78+
- Format check: passed
79+
- Init (no backend): passed
80+
- Validate: passed
81+
- TFLint: passed
82+
- Security: tfsec + Checkov passed
83+
84+
All Terraform checks finished successfully for this run.
85+
EOF
86+
87+
- name: Comment on PR with Terraform CI result
88+
if: always()
89+
uses: actions/github-script@v7
90+
with:
91+
github-token: ${{ secrets.GITHUB_TOKEN }}
92+
script: |
93+
const conclusion = '${{ job.status }}';
94+
const symbols = { success: '✅', failure: '❌', cancelled: '⚪️' };
95+
const symbol = symbols[conclusion] || 'ℹ️';
96+
const body =
97+
`${symbol} Terraform CI finished with status: **${conclusion}**\n\n` +
98+
`Terraform versions tested: 1.6.6, 1.8.5, 1.9.5.\n` +
99+
`See detailed results in the "Checks" tab.`;
100+
const pr = context.payload.pull_request;
101+
if (!pr) {
102+
core.info('No pull_request context, skipping comment.');
103+
} else {
104+
await github.rest.issues.createComment({
105+
owner: context.repo.owner,
106+
repo: context.repo.repo,
107+
issue_number: pr.number,
108+
body
109+
});
110+
}
111+
71112
- name: Comment on PR with Terraform CI result
72113
if: always()
73114
uses: actions/github-script@v7

0 commit comments

Comments
 (0)