terraform-fmt #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: terraform-fmt | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '**.tf' | |
| - '**.tfvars' | |
| - '**.tfvars.json' | |
| permissions: | |
| contents: write | |
| jobs: | |
| terraform-fmt: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the repository | |
| uses: actions/checkout@v4 | |
| - name: Token generator | |
| uses: githubofkrishnadhas/github-access-using-githubapp@v2 | |
| id: token-generation | |
| with: | |
| github_app_id: ${{ secrets.TOKEN_GENERATOR_APPID }} | |
| github_app_private_key: ${{ secrets.TOKEN_GENERATOR_PRIVATE_KEY }} | |
| - name: Set up Terraform | |
| uses: hashicorp/setup-terraform@v2 | |
| with: | |
| terraform_version: 1.7.6 | |
| - name: Run the tree generation script | |
| run: | | |
| terraform fmt -recursive -check | |
| - name: Commit and Push Changes | |
| env: | |
| GITHUB_TOKEN: ${{ steps.token-generation.outputs.token }} | |
| run: | | |
| git config user.name 'github-actions-bot' | |
| git config user.email 'actions@github.com' | |
| git add . | |
| git commit -m "terraform fmt checks" | |
| git push |