PRIME-2371 Non-BC Certification #1191
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |