Skip to content

updating docs #1

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,106 @@ This action has no inputs.

## Usage Examples

### Basic Validation
```yaml
steps:
- name: Checkout code
uses: CSVD/gh-actions-checkout@v4

- name: Setup Terraform
uses: CSVD/gh-actions-setup-terraform@v2
with:
terraform_version: '1.7.3'

- name: Validate Terraform Configuration
id: validate
uses: CSVD/terraform-validate@v1
with:
working-directory: './terraform'

- name: Check Validation Result
if: steps.validate.outputs.is_valid != 'true'
run: |
echo "Validation errors found:"
echo "${{ steps.validate.outputs.stderr }}"
exit 1
```
### Validation with Backend Config
```yaml
steps:
- name: Validate with Backend Config
id: validate
uses: CSVD/terraform-validate@v1
with:
working-directory: './environments/prod'
backend-config: |
region=us-east-1
bucket=my-terraform-state
key=prod/terraform.tfstate
- name: Show Validation Output
run: |
echo "Validation stdout:"
echo "${{ steps.validate.outputs.stdout }}"
```
### Validation with Variables File
```yaml
steps:
- name: Validate with Variables
id: validate
uses: CSVD/terraform-validate@v1
with:
working-directory: './modules/app'
var-file: './environments/test.tfvars'
```
### Complete Workflow with Tests
```yaml
name: Terraform Quality Checks

on:
pull_request:
paths:
- '**.tf'
- '**.tfvars'

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: CSVD/gh-actions-checkout@v4

- name: Setup Terraform
uses: CSVD/gh-actions-setup-terraform@v2
with:
terraform_version: '1.7.3'

- name: Validate and Test
id: validate
uses: CSVD/terraform-validate@v1
with:
working-directory: './terraform'
var-file: './config/dev.tfvars'

- name: Process Results
run: |
if [[ "${{ steps.validate.outputs.is_valid }}" != "true" ]]; then
echo "::error::Validation failed"
echo "${{ steps.validate.outputs.stderr }}"
exit 1
fi
if [[ "${{ steps.validate.outputs.tests_passed }}" != "true" ]]; then
echo "::error::Tests failed"
echo "${{ steps.validate.outputs.stderr }}"
exit 1
fi
echo "All validation and tests passed!"
```
## Requirements
- Terraform must be installed in the runner environment (typically using `hashicorp/setup-terraform` action)
Expand Down