|  | 
|  | 1 | +name: terraform-validation | 
|  | 2 | + | 
|  | 3 | +on: | 
|  | 4 | +  pull_request: | 
|  | 5 | +  push: | 
|  | 6 | +    branches: [main] | 
|  | 7 | + | 
|  | 8 | +jobs: | 
|  | 9 | +  terraform-validation: | 
|  | 10 | +    runs-on: ubuntu-latest | 
|  | 11 | +    steps: | 
|  | 12 | +      - uses: actions/checkout@v3 | 
|  | 13 | + | 
|  | 14 | +      - name: Setup terraform | 
|  | 15 | +        uses: hashicorp/setup-terraform@v2 | 
|  | 16 | +        with: | 
|  | 17 | +          terraform_version: v1.4.0 | 
|  | 18 | +      - name: Install tflint | 
|  | 19 | +        run: | | 
|  | 20 | +          curl -s https://raw.githubusercontent.com/terraform-linters/\ | 
|  | 21 | +          tflint/master/install_linux.sh | bash | 
|  | 22 | +
 | 
|  | 23 | +      - name: Run terraform fmt | 
|  | 24 | +        run: | | 
|  | 25 | +          terraform fmt | 
|  | 26 | +      - name: Run terraform validate | 
|  | 27 | +        run: | | 
|  | 28 | +          terraform validate | 
|  | 29 | +      - name: Run terraform tflint | 
|  | 30 | +        run: | | 
|  | 31 | +          tflint --chdir=terraform/ --recursive | 
|  | 32 | +
 | 
|  | 33 | +      - name: Document cloud infrastructure remote state in README | 
|  | 34 | +        uses: terraform-docs/gh-actions@v1.3.0 | 
|  | 35 | +        with: | 
|  | 36 | +          working-dir: ./terraform/s3-remote-state | 
|  | 37 | +      - name: Document cloud infrastructure in mkdocs | 
|  | 38 | +        uses: terraform-docs/gh-actions@v1.3.0 | 
|  | 39 | +        with: | 
|  | 40 | +          working-dir: ./terraform/aws/modules/infra | 
|  | 41 | +          output-file: ../../../../docs/code/terraform-local-setup.md | 
|  | 42 | +      - name: Document Snowflake account infrastructure in mkdocs | 
|  | 43 | +        uses: terraform-docs/gh-actions@v1.3.0 | 
|  | 44 | +        with: | 
|  | 45 | +          working-dir: ./terraform/snowflake/modules/elt | 
|  | 46 | +          output-file: ../../../../docs/infra/snowflake.md | 
|  | 47 | +      # This shouldn't be necessary but the terraform-docs action has a bug | 
|  | 48 | +      # preventing it from git-adding files outside of 'working-dir'. | 
|  | 49 | +      # See: https://github.com/terraform-docs/gh-actions/pull/108 | 
|  | 50 | +      - name: Commit any files changed by terraform-docs | 
|  | 51 | +        run: | | 
|  | 52 | +          git add docs/code/terraform-local-setup.md | 
|  | 53 | +          git add docs/infra/snowflake.md | 
|  | 54 | +          # Run git commit if changed files are detected | 
|  | 55 | +          if git status --porcelain | grep -q '[AM ][AM ]\s\+\S\+'; then | 
|  | 56 | +            git config --global user.name 'github-actions[bot]' | 
|  | 57 | +            git config --global user.email 'github-actions[bot]@users.noreply.github.com' | 
|  | 58 | +            set -x | 
|  | 59 | +            git commit -m "Automated terraform-docs commit" | 
|  | 60 | +            git push | 
|  | 61 | +            set +x | 
|  | 62 | +          fi | 
0 commit comments