|
| 1 | +name: Integration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: {} |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: integration-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + changed: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + outputs: |
| 18 | + terraform_modules_changed: ${{ steps.filter-terraform-modules.outputs.changed }} |
| 19 | + terraform_modules_files: ${{ steps.filter-terraform-modules.outputs.files }} |
| 20 | + terraform_modules_dirs: ${{ steps.filter-terraform-modules.outputs.dirs }} |
| 21 | + yaml_changed: ${{ steps.filter-yaml.outputs.changed }} |
| 22 | + yaml_files: ${{ steps.filter-yaml.outputs.files }} |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v2 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Get Changed Files |
| 31 | + id: changed-files |
| 32 | + uses: dorny/paths-filter@v2 |
| 33 | + with: |
| 34 | + list-files: json |
| 35 | + filters: | |
| 36 | + modules: |
| 37 | + - 'modules/**' |
| 38 | + yaml: |
| 39 | + - '**/*.yaml' |
| 40 | + - '**/*.yml' |
| 41 | +
|
| 42 | + - name: Filter changed Terraform Modules files to outputs |
| 43 | + id: filter-terraform-modules |
| 44 | + run: | |
| 45 | + dirs=$(echo '${{ steps.changed-files.outputs.modules_files }}' | jq '[.[] | match("modules/[^/]+").string] | unique') |
| 46 | + echo ::set-output name=changed::${{ steps.changed-files.outputs.modules }} |
| 47 | + echo ::set-output name=files::${{ steps.changed-files.outputs.modules_files }} |
| 48 | + echo ::set-output name=dirs::$dirs |
| 49 | +
|
| 50 | + - name: Filter changed YAML files to outputs |
| 51 | + id: filter-yaml |
| 52 | + run: | |
| 53 | + echo ::set-output name=changed::${{ steps.changed-files.outputs.yaml }} |
| 54 | + echo ::set-output name=files::${{ steps.changed-files.outputs.yaml_files }} |
| 55 | +
|
| 56 | +
|
| 57 | + terraform: |
| 58 | + needs: |
| 59 | + - changed |
| 60 | + if: ${{ needs.changed.outputs.terraform_modules_changed != 'false' }} |
| 61 | + runs-on: ubuntu-latest |
| 62 | + |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + path: ${{ fromJson(needs.changed.outputs.terraform_modules_dirs) }} |
| 66 | + |
| 67 | + steps: |
| 68 | + - name: Checkout |
| 69 | + uses: actions/checkout@v2 |
| 70 | + |
| 71 | + - name: Set-up terraform |
| 72 | + uses: hashicorp/setup-terraform@v1 |
| 73 | + |
| 74 | + - name: Terraform fmt |
| 75 | + id: terraform-fmt |
| 76 | + working-directory: ${{ matrix.path }} |
| 77 | + run: terraform fmt -check |
| 78 | + continue-on-error: true |
| 79 | + |
| 80 | + - name: Terraform Validate |
| 81 | + id: terraform-validate |
| 82 | + working-directory: ${{ matrix.path }} |
| 83 | + run: | |
| 84 | + terraform init -backend=false |
| 85 | + terraform validate -no-color |
| 86 | +
|
| 87 | +
|
| 88 | + yaml: |
| 89 | + needs: |
| 90 | + - changed |
| 91 | + if: ${{ needs.changed.outputs.yaml_changed != 'false' }} |
| 92 | + runs-on: ubuntu-latest |
| 93 | + |
| 94 | + steps: |
| 95 | + - name: Checkout |
| 96 | + uses: actions/checkout@v2 |
| 97 | + |
| 98 | + - name: Lint YAML Files |
| 99 | + id: yaml-lint |
| 100 | + run: | |
| 101 | + yamllint . |
0 commit comments