{"id":21261383,"url":"https://github.com/dflook/tofu-fmt-check","last_synced_at":"2026-07-19T00:02:11.370Z","repository":{"id":204303117,"uuid":"708927858","full_name":"dflook/tofu-fmt-check","owner":"dflook","description":"GitHub action to check the formatting of OpenTofu files ","archived":false,"fork":false,"pushed_at":"2025-08-08T13:32:27.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-07T10:25:18.363Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dflook.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["dflook"]}},"created_at":"2023-10-23T17:02:13.000Z","updated_at":"2025-08-08T13:32:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe65f9a2-f54e-453b-a31b-bf3c56fcfd74","html_url":"https://github.com/dflook/tofu-fmt-check","commit_stats":null,"previous_names":["dflook/tofu-fmt-check"],"tags_count":123,"template":false,"template_full_name":null,"purl":"pkg:github/dflook/tofu-fmt-check","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflook%2Ftofu-fmt-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflook%2Ftofu-fmt-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflook%2Ftofu-fmt-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflook%2Ftofu-fmt-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dflook","download_url":"https://codeload.github.com/dflook/tofu-fmt-check/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflook%2Ftofu-fmt-check/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35635260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-18T02:00:07.223Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T04:29:21.903Z","updated_at":"2026-07-19T00:02:11.360Z","avatar_url":"https://github.com/dflook.png","language":null,"funding_links":["https://github.com/sponsors/dflook"],"categories":[],"sub_categories":[],"readme":"# tofu-fmt-check action\n\nThis is one of a suite of OpenTofu related actions - find them at [dflook/terraform-github-actions](https://github.com/dflook/terraform-github-actions).\n\nThis action uses the `tofu fmt` command to check that all files in an OpenTofu configuration directory are in the canonical format.\nThis can be used to check that files are properly formatted before merging.\n\nIf any files are not correctly formatted a failing GitHub check will be added for the file, and the job failed.\n\n## Inputs\n\n* `path`\n\n  The path containing OpenTofu files to check the formatting of.\n\n  - Type: string\n  - Optional\n  - Default: The action workspace\n\n* `workspace`\n\n  OpenTofu workspace to inspect when discovering the OpenTofu version to use, if the version is not otherwise specified.\n  See [dflook/tofu-version](https://github.com/dflook/terraform-github-actions/tree/main/tofu-version#tofu-version-action) for details.\n\n  - Type: string\n  - Optional\n  - Default: `default`\n\n* `variables`\n\n  Variables to set when initializing OpenTofu. This should be valid OpenTofu syntax - like a [variable definition file](https://opentofu.org/docs/language/values/variables/#variable-definitions-tfvars-files).\n  Variables set here override any given in `var_file`s.\n\n  ```yaml\n  with:\n    variables: |\n      image_id = \"${{ secrets.AMI_ID }}\"\n      availability_zone_names = [\n        \"us-east-1a\",\n        \"us-west-1c\",\n      ]\n  ```\n\n  - Type: string\n  - Optional\n\n* `var_file`\n\n  List of tfvars files to use, one per line.\n  Paths should be relative to the GitHub Actions workspace\n\n  ```yaml\n  with:\n    var_file: |\n      common.tfvars\n      prod.tfvars\n  ```\n\n  - Type: string\n  - Optional\n\n* `backend_config`\n\n  List of OpenTofu backend config values, one per line. This is used for discovering the OpenTofu version to use, if the version is not otherwise specified.\n  See [dflook/tofu-version](https://github.com/dflook/terraform-github-actions/tree/main/tofu-version#tofu-version-action) for details.\n\n  ```yaml\n  with:\n    backend_config: token=${{ secrets.BACKEND_TOKEN }}\n  ```\n\n  - Type: string\n  - Optional\n\n* `backend_config_file`\n\n  List of OpenTofu backend config files to use, one per line. This is used for discovering the OpenTofu version to use, if the version is not otherwise specified.\n  See [dflook/tofu-version](https://github.com/dflook/terraform-github-actions/tree/main/tofu-version#tofu-version-action) for details.\n  Paths should be relative to the GitHub Actions workspace\n\n  ```yaml\n  with:\n    backend_config_file: prod.backend.tfvars\n  ```\n\n  - Type: string\n  - Optional\n\n## Outputs\n\n* `failure_reason`\n* `failure-reason`\n\n  When the job outcome is `failure` because the format check failed, this will be set to 'check-failed'.\n  If the job fails for any other reason this will not be set.\n  This can be used with the Actions expression syntax to conditionally run a step when the format check fails.\n\n  - Type: string\n\n## Environment Variables\n\n* `GITHUB_DOT_COM_TOKEN`\n\n  This is used to specify a token for GitHub.com when the action is running on a GitHub Enterprise instance.\n  This is only used for downloading OpenTofu binaries from GitHub.com.\n  If this is not set, an unauthenticated request will be made to GitHub.com to download the binary, which may be rate limited.\n\n  - Type: string\n  - Optional\n\n* `TERRAFORM_CLOUD_TOKENS`\n\n  For the purpose of detecting the OpenTofu version to use from a cloud backend.\n  API tokens for cloud hosts, of the form `\u003chost\u003e=\u003ctoken\u003e`. Multiple tokens may be specified, one per line.\n  These tokens may be used with the `remote` backend and for fetching required modules from the registry.\n\n  e.g:\n\n  ```yaml\n  env:\n    TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_CLOUD_TOKEN }}\n  ```\n\n  With other registries:\n\n  ```yaml\n  env:\n    TERRAFORM_CLOUD_TOKENS: |\n      app.terraform.io=${{ secrets.TF_CLOUD_TOKEN }}\n      tofu.example.com=${{ secrets.TF_REGISTRY_TOKEN }}\n  ```\n\n  - Type: string\n  - Optional\n\n## Example usage\n\nThis example workflow runs on every push and fails if any of the\nOpenTofu files are not formatted correctly.\n\n```yaml\nname: Check file formatting\n\non: [push]\n\njobs:\n  check_format:\n    runs-on: ubuntu-latest\n    name: Check OpenTofu file are formatted correctly\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v4\n\n      - name: tofu fmt\n        uses: dflook/tofu-fmt-check@v2\n        with:\n          path: my-tofu-config\n```\n\nThis example executes a run step only if the format check failed.\n\n```yaml\nname: Check file formatting\n\non: [push]\n\njobs:\n  check_format:\n    runs-on: ubuntu-latest\n    name: Check OpenTofu file are formatted correctly\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v4\n\n      - name: tofu fmt\n        uses: dflook/tofu-fmt-check@v2\n        id: fmt-check\n        with:\n          path: my-tofu-config\n\n      - name: Wrong formatting found\n        if: ${{ failure() \u0026\u0026 steps.fmt-check.outputs.failure_reason == 'check-failed' }}\n        run: echo \"formatting check failed\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflook%2Ftofu-fmt-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdflook%2Ftofu-fmt-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflook%2Ftofu-fmt-check/lists"}