-
Notifications
You must be signed in to change notification settings - Fork 3
78 lines (70 loc) · 2.87 KB
/
destroy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: 'Destroy Environment'
on:
workflow_dispatch:
inputs:
deploy-env:
description: 'Environment to destroy'
required: true
type: choice
options:
- Pre-prod
default: Pre-prod
jobs:
clean_ecr_repositories:
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env }}
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
id: get_env_name
uses: Entepotenz/change-string-case-action-min-dependencies@v1
with:
string: ${{ vars.ENV_NAME }}
- name: Checkout repo
uses: actions/checkout@v4
- name: Delete ecr repostiroy for ${{ vars.ENV_NAME }}
run: |
./deployment/delete_ecr opensupplyhub-batch-${{ steps.get_env_name.outputs.lowercase }}
./deployment/delete_ecr opensupplyhub-${{ steps.get_env_name.outputs.lowercase }}
./deployment/delete_ecr opensupplyhub-kafka-${{ steps.get_env_name.outputs.lowercase }}
./deployment/delete_ecr opensupplyhub-deduplicate-${{ steps.get_env_name.outputs.lowercase }}
./deployment/delete_ecr opensupplyhub-logstash-${{ steps.get_env_name.outputs.lowercase }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: "eu-west-1"
destroy:
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env }}
needs: clean_ecr_repositories
steps:
- name: Get Environment Name for ${{ vars.ENV_NAME }}
id: get_env_name
uses: Entepotenz/change-string-case-action-min-dependencies@v1
with:
string: ${{ vars.ENV_NAME }}
- name: Checkout repo
uses: actions/checkout@v4
- name: Checkout config repository
uses: actions/checkout@v4
with:
repository: 'opensupplyhub/ci-deployment'
path: 'terraform-config'
token: ${{ secrets.PAT }}
- name: Copy tfvars for ${{ vars.ENV_NAME }}
run: |
cat "terraform-config/environments/${{ env.TFVAR_NAME }}" "deployment/environments/${{env.TFVAR_NAME}}" > "deployment/terraform/${{ env.SETTINGS_BUCKET }}.tfvars"
env:
SETTINGS_BUCKET: oshub-settings-${{ steps.get_env_name.outputs.lowercase }}
TFVAR_NAME: terraform-${{steps.get_env_name.outputs.lowercase}}.tfvars
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.4.0
terraform_wrapper: false
- name: Terraform destroy for ${{ vars.ENV_NAME }}
run: ./deployment/infra destroy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SETTINGS_BUCKET: oshub-settings-${{ steps.get_env_name.outputs.lowercase }}
AWS_DEFAULT_REGION: "eu-west-1"