-
Notifications
You must be signed in to change notification settings - Fork 6
73 lines (61 loc) · 2.12 KB
/
ld-demoEnv-deprovision.yaml
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
name: "Remove Demo Environment From K8s and LD"
on:
delete:
branches:
- '*demoenv*'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-east-1
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
ECR_REPOSITORY: ld-core-demo
KUBECTL_VERSION: "v1.23.0"
LD_API_KEY: ${{ secrets.LD_API_KEY }}
jobs:
get-branch-name:
runs-on: ubuntu-latest
outputs:
branch_name: ${{ steps.set_branch_name.outputs.branch_name }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get deleted branch name
id: set_branch_name
run: |
echo "DELETED_BRANCH_NAME=${{ github.event.ref }}"
echo "BRANCH_NAME=${{ github.event.ref }}" >> $GITHUB_ENV
echo "::set-output name=branch_name::${{ github.event.ref }}"
remove-demoenv:
needs: get-branch-name
if: contains(needs.get-branch-name.outputs.branch_name, 'demoenv')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set namespace for deployment
id: set_namespace
run: |
BRANCH_REF=${{ github.event.ref }}
NAMESPACE=${BRANCH_REF#demoenv-}
echo "DEMO_NAMESPACE=${NAMESPACE}" >> $GITHUB_ENV
echo "::set-output name=namespace::$NAMESPACE"
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./.github/workflows/requirements.txt
- name: Delete LD Project for User
id: delete_ld_project
env:
LD_API_KEY: ${{ secrets.LD_API_KEY }}
NAMESPACE: ${{ env.DEMO_NAMESPACE }}
run: |
echo "Deleting LaunchDarkly project for namespace: ${{ env.DEMO_NAMESPACE }}"
python ./.github/workflows/ld_api/delete_ld_project.py
- name: Delete Kubernetes Namespace
uses: kodermax/kubectl-aws-eks@master
with:
args: delete namespace ${{ env.DEMO_NAMESPACE }}