| name: "Terraform E2E Tests" |
|
|
| on: |
| push: |
| branches: |
| - master |
| paths: |
| - 'test/e2e/**.tf' |
| pull_request: |
| paths: |
| - 'test/e2e/**.tf' |
|
|
| concurrency: |
| group: ${{ github.workflow }}-${{ github.ref }} |
| cancel-in-progress: false |
|
|
| jobs: |
| terraform: |
| concurrency: terraform_checkly |
| defaults: |
| run: |
| working-directory: test/e2e |
| env: |
| TF_CLOUD_ORGANIZATION : ${{ secrets.TF_CLOUD_ORGANIZATION }} |
|
|
| name: "Terraform" |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
|
|
| - name: Setup Terraform |
| uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 |
| with: |
| cli_config_credentials_token: ${{ secrets.TF_CLOUD_CHECKLY_API_TOKEN }} |
|
|
| - name: Terraform Format |
| id: fmt |
| run: terraform fmt -check |
|
|
| - name: Terraform Init |
| id: init |
| run: terraform init |
|
|
| - name: Terraform Validate |
| id: validate |
| run: terraform validate -no-color |
|
|
| - name: Terraform Plan |
| id: plan |
| if: github.event_name == 'pull_request' |
| run: terraform plan -no-color |
| continue-on-error: true |
|
|
| - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd |
| if: github.event_name == 'pull_request' |
| env: |
| PLAN: "terraform\n${{ steps.plan.outputs.stdout }}" |
| with: |
| github-token: ${{ secrets.GITHUB_TOKEN }} |
| script: | |
| const output = `#### Terraform Format and Style π\`${{ steps.fmt.outcome }}\` |
| #### Terraform Initialization βοΈ\`${{ steps.init.outcome }}\` |
| #### Terraform Validation π€\`${{ steps.validate.outcome }}\` |
| #### Terraform Plan π\`${{ steps.plan.outcome }}\` |
| |
| <details><summary>Show Plan</summary> |
|
|
| \`\`\`\n |
| ${process.env.PLAN} |
| \`\`\` |
|
|
| </details> |
|
|
| *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; |
|
|
| github.rest.issues.createComment({ |
| issue_number: context.issue.number, |
| owner: context.repo.owner, |
| repo: context.repo.repo, |
| body: output |
| }) |
|
|
| - name: Terraform Plan Status |
| if: steps.plan.outcome == 'failure' |
| run: exit 1 |
|
|
| - name: Terraform Apply |
| if: github.ref == 'refs/heads/master' && github.event_name == 'push' |
| run: terraform apply -auto-approve |
|
|