-
-
Notifications
You must be signed in to change notification settings - Fork 67
48 lines (45 loc) · 1.65 KB
/
cleanup.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
name: Cleanup
on:
pull_request:
types: [ closed ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
cleanup:
name: Uninstall K8s Release for Closed Pull Request
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
# gcloud does not work with Python 3.10 because collections.Mappings was removed in Python 3.10.
- uses: actions/setup-python@v4
with:
python-version: 3.9.15
- name: Auth gcloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GKE_PROJECT }}
- name: Configure gcloud
run: |
gcloud components install gke-gcloud-auth-plugin
gcloud --quiet auth configure-docker
gcloud container clusters get-credentials api-platform-demo --zone europe-west1-c
- name: Uninstall helm release
id: uninstall_helm_release
run: |
export RELEASE_NAME=pr-$(jq --raw-output .pull_request.number $GITHUB_EVENT_PATH)
echo "Uninstalling release ${RELEASE_NAME}"
if ! helm uninstall ${RELEASE_NAME} --kube-context nonprod --wait ; then
echo "HELM Uninstall has failed !"
echo "Please ask the SRE team to manually clean remaining objects"
exit 1
fi
echo "HELM uninstall successfull"
echo "Cleaning remaining PVC..."
kubectl delete pvc -l app.kubernetes.io/instance=$RELEASE_NAME