Skip to content

Commit

Permalink
updating docs (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnol377 committed Mar 27, 2025
1 parent e973f29 commit 19f9f4c
Showing 1 changed file with 100 additions and 0 deletions.
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

0 comments on commit 19f9f4c

Please sign in to comment.