terraform-github-actions

tofu-validate action

This is one of a suite of OpenTofu related actions - find them at dflook/terraform-github-actions.

This action uses the tofu validate command to check that an OpenTofu configuration is valid. This can be used to check that a configuration is valid before creating a plan.

Failing GitHub checks will be added for any problems found.

If the OpenTofu configuration is not valid, the build is failed.

Inputs

Outputs

Environment Variables

Example usage

This example workflow runs on every push and fails if the OpenTofu configuration is invalid.

on: [push]

jobs:
  validate:
    runs-on: ubuntu-latest
    name: Validate OpenTofu module
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: tofu validate
        uses: dflook/tofu-validate@v1
        with:
          path: my-tofu-config

This example executes a run step only if the validation failed.

on: [push]

jobs:
  validate:
    runs-on: ubuntu-latest
    name: Validate OpenTofu module
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: tofu validate
        uses: dflook/tofu-validate@v1
        id: validate
        with:
          path: my-tofu-config

      - name: Validate failed
        if: $
        run: echo "tofu validate failed"