|
| 1 | +--- |
| 2 | +################ |
| 3 | +## Run linter ## |
| 4 | +################ |
| 5 | + |
| 6 | +# |
| 7 | +# Documentation: |
| 8 | +# https://help.github.com/en/articles/workflow-syntax-for-github-actions |
| 9 | +# |
| 10 | + |
| 11 | +name: Lint |
| 12 | +on: |
| 13 | + push: |
| 14 | + branches: [ main ] |
| 15 | + pull_request: |
| 16 | + branches: [ main ] |
| 17 | + |
| 18 | +########################## |
| 19 | +# Prevent duplicate jobs # |
| 20 | +########################## |
| 21 | +concurrency: |
| 22 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + pull-requests: write |
| 28 | + |
| 29 | +############### |
| 30 | +# Run the job # |
| 31 | +############### |
| 32 | +jobs: |
| 33 | + ########## |
| 34 | + # TF fmt # |
| 35 | + ########## |
| 36 | + tf-fmt: |
| 37 | + name: FMT |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + ############################ |
| 41 | + # Checkout the source code # |
| 42 | + ############################ |
| 43 | + - name: Checkout Code |
| 44 | + |
| 45 | + |
| 46 | + ##################### |
| 47 | + # Run Terraform fmt # |
| 48 | + ##################### |
| 49 | + - name: Terraform fmt |
| 50 | + |
| 51 | + |
| 52 | + ########## |
| 53 | + # TFLint # |
| 54 | + ########## |
| 55 | + tf-lint: |
| 56 | + name: TFLint |
| 57 | + runs-on: ubuntu-latest |
| 58 | + steps: |
| 59 | + ############################ |
| 60 | + # Checkout the source code # |
| 61 | + ############################ |
| 62 | + - name: Checkout Code |
| 63 | + |
| 64 | + |
| 65 | + ################# |
| 66 | + # Cache plugins # |
| 67 | + ################# |
| 68 | + - name: Cache plugin dir |
| 69 | + |
| 70 | + with: |
| 71 | + path: ~/.tflint.d/plugins |
| 72 | + key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }} |
| 73 | + |
| 74 | + ################ |
| 75 | + # Setup TFLint # |
| 76 | + ################ |
| 77 | + - name: Setup TFLint |
| 78 | + uses: terraform-linters/setup-tflint@v2 |
| 79 | + with: |
| 80 | + tflint_version: v0.42.2 |
| 81 | + |
| 82 | + ############### |
| 83 | + # Init TFLint # |
| 84 | + ############### |
| 85 | + - name: Init TFLint |
| 86 | + run: tflint --init |
| 87 | + |
| 88 | + ############## |
| 89 | + # Run TFLint # |
| 90 | + ############## |
| 91 | + - name: Run TFLint |
| 92 | + run: tflint -f compact |
| 93 | + |
| 94 | + ########### |
| 95 | + # TF docs # |
| 96 | + ########### |
| 97 | + tf-docs: |
| 98 | + name: Docs |
| 99 | + if: ${{ github.event_name == 'pull_request' }} |
| 100 | + permissions: |
| 101 | + contents: write |
| 102 | + pull-requests: write |
| 103 | + |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + ############################ |
| 107 | + # Checkout the source code # |
| 108 | + ############################ |
| 109 | + - name: Checkout Code |
| 110 | + |
| 111 | + with: |
| 112 | + ref: ${{ github.event.pull_request.head.ref }} |
| 113 | + |
| 114 | + #################### |
| 115 | + # Update README.md # |
| 116 | + #################### |
| 117 | + - name: Terraform docs |
| 118 | + uses: terraform-docs/[email protected] |
| 119 | + with: |
| 120 | + ref: ${{ github.event.pull_request.head.ref }} |
| 121 | + config-file: .terraform-docs.yml |
| 122 | + git-push: true |
0 commit comments