2023-01-05 22:25:54 +03:00
|
|
|
name: "Terraform E2E Tests"
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2024-01-23 10:32:20 +03:00
|
|
|
paths:
|
|
|
|
- 'test/e2e/**.tf'
|
2023-01-05 22:25:54 +03:00
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- 'test/e2e/**.tf'
|
|
|
|
|
2023-09-20 15:06:04 +03:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: false
|
|
|
|
|
2023-01-05 22:25:54 +03:00
|
|
|
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
|
2023-09-14 15:13:34 +03:00
|
|
|
uses: actions/checkout@v4
|
2023-01-05 22:25:54 +03:00
|
|
|
|
|
|
|
- name: Setup Terraform
|
2023-11-16 03:07:21 +03:00
|
|
|
uses: hashicorp/setup-terraform@v3
|
2023-01-05 22:25:54 +03:00
|
|
|
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
|
2024-01-23 10:32:20 +03:00
|
|
|
|
2023-01-05 22:25:54 +03:00
|
|
|
- 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
|
|
|
|
|
2024-01-03 18:30:41 +03:00
|
|
|
- uses: actions/github-script@v7
|
2023-01-05 22:25:54 +03:00
|
|
|
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
|