Delete Feature Environment #11
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: Delete Feature Environment | |
on: | |
delete: | |
branches-ignore: | |
- 'qa' | |
- 'prod' | |
jobs: | |
prune: | |
if: ${{ !startsWith(github.event.ref, 'qa') || !startsWith(github.event.ref, 'prod')}} | |
name: Destroy Feature Environment | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
env: | |
TERRAFORM_ENV_BASE64: ${{ secrets.TERRAFORM_ENV_BASE64 }} | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
- run: |- | |
_tfdir=terraform | |
echo $TERRAFORM_ENV_BASE64 | base64 -d > tfvars | |
source tfvars | |
echo "base: ${GITHUB_BASE_REF}" | |
echo "ref: ${{ github.event.ref }}" | |
_ref=$(echo "${{ github.event.ref }}" | sed -e "s#refs/heads/##g") | |
export TF_VAR_pingone_environment_name="$(echo "${_ref}" | sed -e "s#refs/heads/##g")" | |
terraform -chdir=${_tfdir} init \ | |
-backend-config="bucket=$TF_VAR_tf_state_bucket" \ | |
-backend-config="region=$TF_VAR_tf_state_region" \ | |
-backend-config="key=${TF_VAR_tf_state_key_prefix}/dev/${TF_VAR_pingone_environment_name}/terraform.tfstate" | |
terraform -chdir=${_tfdir} destroy --auto-approve |