Skip to content

Commit

Permalink
chore(ENG-872): re-writing docs slightly to make more focused to Terr…
Browse files Browse the repository at this point in the history
…aform
  • Loading branch information
Tristan Watson committed Aug 8, 2024
1 parent ce7a72e commit cd0010b
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 59 deletions.
24 changes: 24 additions & 0 deletions .github/workflows
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: YAML Syntax Check

on: [push, pull_request]

jobs:
lint-yaml:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Install yamllint
run: |
python -m pip install --upgrade pip
pip install yamllint

- name: Run yamllint
run: yamllint .
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ actions/
│ └── README.md
```

### Terraform Action 🌍
### Terraform Actions 🌍

**Location:** `actions/terraform`

Expand All @@ -27,18 +27,17 @@ actions/
### How to Use

```yaml
name: Terraform Check

on: [push, pull_request]

jobs:
terraform-job:
example-job:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run Terraform Action
- name: Run Terraform Action from oak-terraform-actions
uses: oaknational/oak-actions/actions/terraform@main
with:
example_input: "value"
```
> **Note:** Replace `example_input` with the required parameters as specified in the action's `README.md`.

For more details, visit the [oaknational/oak-actions repository](https://github.com/oaknational/oak-actions).
71 changes: 40 additions & 31 deletions actions/terraform/action.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
name: Common Terraform Checks
run-name: 🔍 Terraform Checks - triggered by @${{ github.actor }}
on: [push]
jobs:
terraform-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.5.7 # See upgrading docs regarding tfenv: https://www.notion.so/oaknationalacademy/Terraform-The-Oak-Guide-to-b3930c13433f48fa890968636f495098?pvs=4#4dee54a2e4714f55957b047c1d94c62a
- name: "INFO: Acertain Terraform Version"
shell: bash
run: terraform --version
- name: "INFO: Linting Terraform Files"
shell: bash
run: |
cd infrastructure
terraform fmt -check $(find . -name '*tf')
- name: "INFO: Validate terraform configs"
shell: bash
run: |
cd infrastructure
for d in $(find . -type d -mindepth 1 -maxdepth 1)
do
echo "Validating the $d config"
cd $d
terraform init -backend=false
terraform validate
cd ..
done
name: "Terraform Checks"
description: "Perform common Terraform checks"
inputs:
terraform_version:
description: "Terraform version to use"
required: false
default: "1.5.7"
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ inputs.terraform_version }}

- name: "INFO: Ascertain Terraform Version"
shell: bash
run: terraform --version

- name: "INFO: Linting Terraform Files"
shell: bash
run: |
cd infrastructure
terraform fmt -check $(find . -name '*tf')
- name: "INFO: Validate Terraform Configs"
shell: bash
run: |
cd infrastructure
for d in $(find . -type d -mindepth 1 -maxdepth 1)
do
echo "Validating the $d config"
cd $d
terraform init -backend=false
terraform validate
cd ..
done
12 changes: 12 additions & 0 deletions examples/define-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Terraform Check - With Defined Version

on: [push, pull_request]

jobs:
terraform-checks:
runs-on: ubuntu-latest
steps:
- name: Run Terraform Checks Action from oak-terraform-actions
uses: oaknational/oak-actions/actions/terraform-checks@main
with:
terraform_version: 1.5.7 # or any other version as needed
File renamed without changes.
13 changes: 13 additions & 0 deletions examples/general-use/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Terraform Check

on: [push, pull_request]

jobs:
example-job:
runs-on: ubuntu-latest

steps:
- name: Run Terraform Action from oak-terraform-actions
uses: oaknational/oak-actions/actions/terraform@main
with:
example_input: "value"
19 changes: 0 additions & 19 deletions examples/terraform/action.yml

This file was deleted.

0 comments on commit cd0010b

Please sign in to comment.