Add TF/PR/Shell linting to repository #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Terraform fmt diff | |
on: | |
pull_request: | |
types: | |
- opened | |
- edited | |
- reopened | |
- synchronize | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
repository-projects: write | |
id-token: write | |
name: Check Terraform file are formatted correctly | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: setup terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: run terraform fmt diff | |
run: terraform fmt -diff -recursive -write=false | tee diff.log | |
- name: check for empty diff | |
id: diff_check | |
run: | | |
if [[ -s diff.log ]]; then | |
error_message=$(cat diff.log | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/%0A/g') | |
echo "::error::Terraform formatting issues found. Run 'terraform fmt -recursive' to fix them.%0A%0A$error_message" | |
exit 1 | |