e2e #844
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: e2e | |
on: | |
# Allow invokable workflow run | |
workflow_dispatch: | |
# Nightly | |
schedule: | |
- cron: 25 6 * * * | |
jobs: | |
initialize-tfc-resources: | |
runs-on: "ubuntu-latest" | |
env: | |
TF_CLOUD_ORGANIZATION: ${{ vars.TF_CLOUD_ORGANIZATION }} | |
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} | |
TF_WORKSPACE: ${{ vars.TF_WORKSPACE }} | |
defaults: | |
run: | |
working-directory: .github/terraform/tfe | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- uses: hashicorp/setup-terraform@v1 | |
id: terraform-setup | |
with: | |
cli_config_credentials_token: ${{ env.TF_API_TOKEN }} | |
- name: Terraform Init | |
id: init | |
run: terraform init | |
- name: Terraform create CI workspaces | |
run: | | |
terraform apply \ | |
-var "organization=$TF_CLOUD_ORGANIZATION" \ | |
--auto-approve -input=false | |
create-runs: | |
runs-on: "ubuntu-latest" | |
needs: initialize-tfc-resources | |
strategy: | |
matrix: | |
include: | |
- speculative: true | |
save_plan: false | |
- speculative: false | |
save_plan: true | |
env: | |
TF_CLOUD_ORGANIZATION: ${{ vars.TF_CLOUD_ORGANIZATION }} | |
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} | |
TF_LOG: DEBUG | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- uses: ./.github/actions/test-upload-configuration | |
id: upload | |
with: | |
workspace: ci-workspace-test | |
directory: .github/terraform/workspace | |
speculative: ${{ matrix.speculative }} | |
provisional: ${{ matrix.save_plan }} | |
- uses: ./.github/actions/test-create-run | |
id: create-run | |
with: | |
configuration_version: ${{ steps.upload.outputs.configuration_version_id }} | |
workspace: ci-workspace-test | |
plan_only: ${{ matrix.speculative }} | |
save_plan: ${{ matrix.save_plan }} | |
- uses: ./.github/actions/test-plan-output | |
id: plan | |
with: | |
plan: ${{ steps.create-run.outputs.plan_id }} | |
- name: Echo Outputs | |
run: | | |
echo "Add: ${{ steps.plan.outputs.add }}" | |
echo "Change: ${{ steps.plan.outputs.change }}" | |
echo "Destroy: ${{ steps.plan.outputs.destroy }}" | |
echo "Run Status: ${{ steps.create-run.outputs.run_status }}" | |
destroy-tfc-resources: | |
runs-on: "ubuntu-latest" | |
defaults: | |
run: | |
working-directory: .github/terraform/tfe | |
env: | |
TF_CLOUD_ORGANIZATION: ${{ vars.TF_CLOUD_ORGANIZATION }} | |
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} | |
TF_WORKSPACE: ${{ vars.TF_WORKSPACE }} | |
needs: create-runs | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- uses: hashicorp/setup-terraform@v1 | |
id: terraform-setup | |
with: | |
cli_config_credentials_token: ${{ env.TF_API_TOKEN }} | |
- name: Terraform Init | |
id: init | |
run: terraform init | |
- name: Terraform destroy CI workspaces | |
run: | | |
terraform destroy \ | |
-var "organization=$TF_CLOUD_ORGANIZATION" \ | |
--auto-approve -input=false |