1
+ name : ' K8: Delete'
2
+
3
+ on :
4
+ workflow_call :
5
+ inputs :
6
+ deployment_name :
7
+ description : ' Deployment Name'
8
+ required : true
9
+ type : string
10
+
11
+ # Special permissions required for OIDC authentication
12
+ permissions :
13
+ id-token : write
14
+ contents : read
15
+ actions : read
16
+
17
+ jobs :
18
+ k8-cluster-delete :
19
+ name : ' K8: Delete Cluster Resources'
20
+ runs-on : [self-hosted, "${{ github.ref_name }}"]
21
+ environment : ${{ github.ref_name }}
22
+ env :
23
+ KUBERNETES_NAMESPACE : " ${{ vars.KUBERNETES_NAMESPACE }}"
24
+ KUBERNETES_CLUSTER_NAME : " ${{ vars.KUBERNETES_CLUSTER_NAME }}"
25
+ KUBERNETES_MANIFEST_PATH : " ${{ vars.KUBERNETES_MANIFEST_PATH }}"
26
+ AZURE_RESOURCE_GROUP : " ${{ vars.AZURE_RESOURCE_GROUP }}"
27
+ AZURE_STORAGE_ACCOUNT : ${{ vars.AZURE_STORAGE_ACCOUNT }}
28
+ AZURE_STORAGE_FILE_SHARE : ${{ vars.AZURE_STORAGE_FILE_SHARE }}
29
+ AZCOPY_VERSION : " v10"
30
+ steps :
31
+ # Checkout the repository to the GitHub Actions runner
32
+ - name : Checkout
33
+ uses : actions/checkout@v4
34
+
35
+ - name : GitHub Configuration
36
+ run : git config --global url."https://oauth2:${{ secrets.GH_TOKEN }}@github.com".insteadOf https://github.com
37
+
38
+ - name : Clone cicd-deployment-scripts
39
+ run : git clone https://github.com/code-kern-ai/cicd-deployment-scripts.git
40
+
41
+ # Install the latest version of Kubernetes CLI and configure the Kubernetes CLI configuration file with a Kubernetes Cloud user API token
42
+ - name : Azure Login
43
+ uses : azure/login@v2
44
+ with :
45
+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
46
+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
47
+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
48
+
49
+ # Use kubelogin to configure your kubeconfig for Azure auth
50
+ - name : Set up kubelogin for non-interactive login
51
+ uses : azure/use-kubelogin@v1
52
+ with :
53
+ kubelogin-version : ' v0.0.25'
54
+
55
+ - uses : azure/aks-set-context@v3
56
+ with :
57
+ resource-group : ${{ env.AZURE_RESOURCE_GROUP }}
58
+ cluster-name : ${{ env.KUBERNETES_CLUSTER_NAME }}
59
+ admin : ' false'
60
+ use-kubelogin : ' true'
61
+
62
+ - name : Delete Cluster Deployment
63
+ shell : bash
64
+ run : |
65
+ bash cicd-deployment-scripts/k8s/delete.sh \
66
+ -n ${{ env.KUBERNETES_NAMESPACE }} \
67
+ -d ${{ inputs.deployment_name }}
68
+
0 commit comments