-
Notifications
You must be signed in to change notification settings - Fork 11
45 lines (37 loc) · 1.9 KB
/
pr-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
name: Cleanup Closed PRs
on:
pull_request:
types: [ closed ]
jobs:
cleanup:
runs-on: ubuntu-20.04
environment: Development
steps:
- name: Install OC
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.6"
- name: Authenticate and set context
uses: redhat-actions/[email protected]
with:
openshift_server_url: ${{secrets.OPENSHIFT_SERVER_URL}}
openshift_token: ${{secrets.OPENSHIFT_SERVICE_TOKEN}}
namespace: ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}}
- name: "Delete Artifacts for closed PR"
run: |
oc delete all,pvc,secrets,route,ingress,configmaps -n ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} -l app.kubernetes.io/part-of=pr-${{ github.event.number }}
- name: "Cleanup old pods"
run: |
for pod in $(oc get pods | grep "Error\|Failed\|Completed\|ImagePullBackOff" | awk '{print $1}'); do oc delete pod -n ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} --grace-period=1 ${pod}; done
- name: "Cleanup old Replication Controllers"
run: |
oc adm prune deployments -n ${{secrets.OPENSHIFT_LICENSE_PLATE}}-${{secrets.OPENSHIFT_ENVIRONMENT}} --keep-complete=1 --confirm
# Commenting out until fix for this is determined.
# - name: "Delete PR database"
# run: |
# oc exec db-task-runner -- dropdb prime-pr-${{ github.event.number }}
- name: "Cleanup Container Images"
run: |
oc tag -d ${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-frontend:pr-${{ github.event.number }} && \
oc tag -d ${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-document-manager:pr-${{ github.event.number }} && \
oc tag -d ${{secrets.OPENSHIFT_LICENSE_PLATE}}-tools/prime-webapi-backend:pr-${{ github.event.number }}