changes #17
This file contains 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: CI checks | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v3 | |
# Making sure all code is formatted as one piece | |
- name: Terraform Format Check | |
run: | | |
terraform fmt -recursive | |
if [ -n "$(git diff)" ]; then | |
echo "Some terraform files need to be formatted. Run 'terraform fmt -recursive' to fix them." | |
exit 1 | |
else | |
echo "No changes made by terraform fmt" | |
fi | |
# Making sure that the terraform code has no mistakes | |
- name: Terraform Validation Check | |
run: | | |
for FOLDER in modules/*; do | |
pushd $FOLDER | |
terraform init | |
terraform validate | |
if [ $? -ne 0 ]; then | |
echo "Terraform validation failed in $FOLDER" | |
popd | |
exit 1 | |
fi | |
popd | |
done | |
- name: Terraform linting using Checkov | |
run: | | |
for FOLDER in modules/*; do | |
if ! checkov -d $FOLDER; then | |
echo "Checkov tests failed. please fix it and run it again." | |
exit 1 | |
else | |
echo "Checkov tests finished successfully. continue." | |
fi | |
done |