Skip to content

Test tf

Test tf #8

Workflow file for this run

name: 'Verify Terraform syntax'
on:
# Triggers the workflow on push or pull request events but only for default and protected branches
push:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: read
actions: read
id-token: write # Required for Octo STS
jobs:
terraform_check:
name: 'Check ${{matrix.directory}} directory'
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
matrix:
directory: [test]
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
- uses: octo-sts/action@6177b4481c00308b3839969c3eca88c96a91775f # v1.0.0
id: octo-sts
with:
scope: kartverket/terraform-modules
identity: kartverket_repos
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ steps.octo-sts.outputs.token }}
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
terraform_version: 1.6.6
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
working-directory: ${{matrix.directory}}
run: terraform init -backend=false
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
working-directory: ${{matrix.directory}}
run: terraform validate
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
working-directory: ${{matrix.directory}}
run: |
terraform fmt -check || { echo '
FAILURE! The above files are not properly formatted.
Run `terraform fmt` in the ${{matrix.directory}} directory, commit the changed files and push to fix the issue' >&2; exit 1; }