|
| 1 | +name: Integration (Terraform) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: {} |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: terraform-integration-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + changed: |
| 15 | + name: Filter Changed Files and Directories |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + outputs: |
| 19 | + changed: ${{ steps.set-outputs.outputs.changed }} |
| 20 | + modified: ${{ steps.set-outputs.outputs.modified }} |
| 21 | + changed_files: ${{ steps.set-outputs.outputs.changed_files }} |
| 22 | + modified_files: ${{ steps.set-outputs.outputs.modified_files }} |
| 23 | + changed_directories: ${{ steps.set-outputs.outputs.changed_directories }} |
| 24 | + modified_directories: ${{ steps.set-outputs.outputs.modified_directories }} |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Get Changed Files |
| 33 | + id: changed-files |
| 34 | + uses: tj-actions/changed-files@v41 |
| 35 | + with: |
| 36 | + files: | |
| 37 | + modules/** |
| 38 | + examples/** |
| 39 | + json: true |
| 40 | + |
| 41 | + - name: Get Changed Directories |
| 42 | + id: changed-directories |
| 43 | + uses: tj-actions/changed-files@v41 |
| 44 | + with: |
| 45 | + files: | |
| 46 | + modules/** |
| 47 | + examples/** |
| 48 | + dir_names: "true" |
| 49 | + dir_names_max_depth: 2 |
| 50 | + json: true |
| 51 | + |
| 52 | + - name: Set outputs |
| 53 | + id: set-outputs |
| 54 | + run: | |
| 55 | + echo "changed=${{ steps.changed-directories.outputs.any_changed }}" >> $GITHUB_OUTPUT |
| 56 | + echo "modified=${{ steps.changed-directories.outputs.any_modified }}" >> $GITHUB_OUTPUT |
| 57 | +
|
| 58 | + echo "changed_files=${{ steps.changed-files.outputs.all_changed_files }}" >> $GITHUB_OUTPUT |
| 59 | + echo "modified_files=${{ steps.changed-files.outputs.all_modified_files }}" >> $GITHUB_OUTPUT |
| 60 | +
|
| 61 | + echo "changed_directories=${{ steps.changed-directories.outputs.all_changed_files }}" >> $GITHUB_OUTPUT |
| 62 | + echo "modified_directories=${{ steps.changed-directories.outputs.all_modified_files }}" >> $GITHUB_OUTPUT |
| 63 | +
|
| 64 | +
|
| 65 | + terraform: |
| 66 | + name: Lint (terraform) |
| 67 | + needs: |
| 68 | + - changed |
| 69 | + if: ${{ needs.changed.outputs.modified == 'true' }} |
| 70 | + uses: tedilabs/.github/.github/workflows/terraform.terraform.yaml@main |
| 71 | + |
| 72 | + strategy: |
| 73 | + matrix: |
| 74 | + path: ${{ fromJson(needs.changed.outputs.modified_directories) }} |
| 75 | + |
| 76 | + with: |
| 77 | + terraform_target_dir: ${{ matrix.path }} |
| 78 | + terraform_version: latest |
| 79 | + terraform_host: app.terraform.io |
| 80 | + secrets: |
| 81 | + gh_token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + terraform_token: ${{ secrets.TERRAFORM_TOKEN }} |
| 84 | + |
| 85 | + |
| 86 | + tflint: |
| 87 | + name: Lint (tflint) |
| 88 | + needs: |
| 89 | + - changed |
| 90 | + if: ${{ needs.changed.outputs.modified == 'true' }} |
| 91 | + uses: tedilabs/.github/.github/workflows/terraform.tflint.yaml@main |
| 92 | + |
| 93 | + strategy: |
| 94 | + matrix: |
| 95 | + path: ${{ fromJson(needs.changed.outputs.modified_directories) }} |
| 96 | + |
| 97 | + with: |
| 98 | + tflint_version: latest |
| 99 | + tflint_config_file: .tflint.hcl |
| 100 | + tflint_target_dir: ${{ matrix.path }} |
| 101 | + tflint_recursive_enabled: false |
| 102 | + tflint_terraform_init_enabled: true |
| 103 | + terraform_version: latest |
| 104 | + terraform_host: app.terraform.io |
| 105 | + secrets: |
| 106 | + gh_token: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + terraform_token: ${{ secrets.TERRAFORM_TOKEN }} |
0 commit comments