Scheduled Terraform Test #138
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: Scheduled Terraform Test | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Runs every day at midnight UTC | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
terratest: | |
name: Run Terratest | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.18 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: Install Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 0.13.1 | |
- name: Download Go Modules | |
working-directory: test | |
run: go mod download | |
- name: Run Terratest | |
working-directory: test | |
run: go test -v | |
terraform-compliance: | |
name: Run Terraform Compliance | |
runs-on: ubuntu-22.04 | |
needs: terratest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: Set up Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 0.13.1 | |
- name: Terraform Init | |
run: terraform init -backend=false | |
working-directory: ./example | |
- name: Terraform Plan | |
run: terraform plan -out=tfplan -input=false | |
working-directory: ./example | |
- name: terraform-compliance | |
uses: terraform-compliance/github_action@main | |
with: | |
plan: ./example/tfplan | |
features: ./compliance/features |