|
| 1 | +# This is a Terraform-managed file; manual changes will be overwritten. |
| 2 | +# see https://github.com/workloads/github-organization/blob/main/templates/workflows/terraform.tftpl.yml |
| 3 | + |
| 4 | +--- |
| 5 | + |
| 6 | +name: "Code Quality: Terraform" |
| 7 | + |
| 8 | +# yamllint disable-line rule:truthy |
| 9 | +on: |
| 10 | + push: |
| 11 | + |
| 12 | +# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions |
| 13 | +permissions: read-all |
| 14 | + |
| 15 | +jobs: |
| 16 | + workflow: |
| 17 | + # only run if workflows are enabled |
| 18 | + if: ${{ vars.ENABLE_WORKFLOWS == 'true' }} |
| 19 | + |
| 20 | + # see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency |
| 21 | + concurrency: |
| 22 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | + name: Terraform |
| 26 | + runs-on: ubuntu-latest |
| 27 | + timeout-minutes: 10 |
| 28 | + |
| 29 | + steps: |
| 30 | + # see https://github.com/actions/checkout/releases/tag/v4.2.2 |
| 31 | + - name: Checkout Repository |
| 32 | + uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" # ref: `tags/v4.2.2` |
| 33 | + with: |
| 34 | + fetch-depth: 1 |
| 35 | + |
| 36 | + # see https://github.com/hashicorp/setup-terraform/releases/tag/v3.1.2 |
| 37 | + - name: Set up Terraform |
| 38 | + uses: "hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd" # ref: `tags/v3.1.2` |
| 39 | + with: |
| 40 | + terraform_wrapper: false |
| 41 | + |
| 42 | + # `TERRAFORM_VERSION` is a GitHub Actions Organization variable |
| 43 | + # see https://github.com/organizations/workloads/settings/variables/actions |
| 44 | + terraform_version: "${{ vars.TERRAFORM_VERSION }}" |
| 45 | + |
| 46 | + - name: Initialize Terraform |
| 47 | + run: terraform init |
| 48 | + env: |
| 49 | + working-dir: "./" |
| 50 | + |
| 51 | + - name: Format Terraform Code |
| 52 | + run: terraform fmt -check -recursive |
| 53 | + env: |
| 54 | + working-dir: "./" |
| 55 | + |
| 56 | + workflow-inactive: |
| 57 | + # only run if workflows are disabled |
| 58 | + if: ${{ vars.ENABLE_WORKFLOWS != 'true' }} |
| 59 | + |
| 60 | + name: Workflow Status |
| 61 | + runs-on: ubuntu-latest |
| 62 | + timeout-minutes: 1 |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Display Workflow Status |
| 66 | + # shellcheck disable=SC2006 |
| 67 | + run: echo "::notice title='Workflow is not currently active'::'Check if `ENABLE_WORKFLOWS` is set to `true`.'" |
0 commit comments