Destroy feature branch application #460
This file contains 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: Destroy feature branch application | |
on: | |
delete: | |
branches: | |
- 'build/*' | |
- 'chore/*' | |
- 'ci/*' | |
- 'docs/*' | |
- 'feat/*' | |
- 'fix/*' | |
- 'perf/*' | |
- 'refactor/*' | |
- 'revert/*' | |
- 'style/*' | |
- 'test/*' | |
workflow_dispatch: | |
jobs: | |
feature-branch-workspace: | |
name: Get Terraform Workspace form Terraform apply outputs | |
uses: codingones/github-actions-workflows/.github/workflows/create-terraform-cloud-workspace-for-aws-ephemeral-environment.terraform.yml@main | |
with: | |
product: 'cartographie-nationale' | |
service: 'client' | |
branch: ${{ github.event.ref }} | |
secrets: | |
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
destroy-feature-branch-environment: | |
name: Destroy feature branch environment | |
needs: | |
- feature-branch-workspace | |
uses: codingones/github-actions-workflows/.github/workflows/destroy.terraform.yml@main | |
with: | |
infrastructure-repository: 'anct-cartographie-nationale/client-infrastructure' | |
workspace-name: ${{ needs.feature-branch-workspace.outputs.tf-workspace }} | |
secrets: | |
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} | |
remove-terraform-workspace: | |
name: Remove Terraform Workspace | |
needs: | |
- feature-branch-workspace | |
- destroy-feature-branch-environment | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delete Terraform API call | |
run: >- | |
curl | |
--header "Authorization: Bearer ${{ secrets.TF_API_TOKEN }}" | |
--header "Content-Type: application/vnd.api+json" | |
--request DELETE | |
https://app.terraform.io/api/v2/organizations/cartographie-nationale/workspaces/client-${{ needs.feature-branch-workspace.outputs.tf-workspace }} |